-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodelab-java.html
More file actions
302 lines (274 loc) · 11.2 KB
/
codelab-java.html
File metadata and controls
302 lines (274 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ai CodeLab - Core Documentation</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Modern Styles -->
<link rel="stylesheet" href="styles.css">
<style>
.study-grid {
display: grid;
grid-template-columns: 3fr 1fr;
gap: 3rem;
max-width: 1400px;
margin: 0 auto;
}
.study-content {
background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
border: 1px solid var(--glass-border);
border-radius: 20px;
padding: 3rem;
backdrop-filter: blur(20px);
color: var(--text-pure);
}
.study-content h1, .study-content h2, .study-content h3 {
color: var(--secondary);
margin-top: 2.5rem;
margin-bottom: 1rem;
border-bottom: 1px solid var(--glass-border);
padding-bottom: 0.5rem;
}
.study-content h1 {
color: var(--primary);
font-size: 3rem;
}
.study-content p, .study-content li {
margin-bottom: 1.2rem;
color: var(--text-muted);
line-height: 1.8;
font-size: 1.05rem;
}
.study-content ul, .study-content ol {
margin-left: 2rem;
margin-bottom: 2rem;
}
.study-content pre {
background: rgba(0,0,0,0.6);
border: 1px solid var(--glass-border);
padding: 1.5rem;
border-radius: 10px;
overflow-x: auto;
margin-bottom: 2rem;
color: var(--accent);
font-family: monospace;
box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.study-sidebar {
background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
border: 1px solid var(--glass-border);
border-radius: 20px;
padding: 2rem;
backdrop-filter: blur(20px);
position: sticky;
top: 100px;
height: fit-content;
}
.study-sidebar h2 {
color: var(--primary);
margin-bottom: 1.5rem;
border-bottom: 1px solid var(--glass-border);
padding-bottom: 0.5rem;
font-size: 1.2rem;
}
.study-sidebar a {
display: flex;
align-items: center;
gap: 1rem;
padding: 0.5rem 0;
color: var(--text-muted);
transition: all 0.3s;
}
.study-sidebar a:hover {
color: var(--secondary);
transform: translateX(5px);
}
@media (max-width: 900px) {
.study-grid { grid-template-columns: 1fr; }
.study-sidebar { position: relative; top: 0; }
}
</style>
</head>
<body>
<!-- Custom Cursor -->
<div id="custom-cursor"></div>
<!-- Animated Mesh Gradient Background -->
<div class="mesh-bg">
<div class="blob blob-1"></div>
<div class="blob blob-2"></div>
<div class="blob blob-3"></div>
</div>
<!-- Modern Extreme Navbar -->
<nav>
<div class="logo-container">
<i class="fas fa-robot"></i>
<span>CodeLab<span style="color:var(--primary)">.ai</span></span>
</div>
<div class="nav-links">
<a href="index.html">Platform</a>
<a href="courses.html">Syllabus</a>
<a href="study.html" class="active">Resources</a>
<a href="join.html">Community</a>
</div>
<div style="display:flex;gap:10px;">
<a href="login.html" class="magnetic-btn" style="padding: 0.5rem 1.5rem; font-size: 0.9rem;"><span>Login</span></a>
</div>
</nav>
<!-- Page Title Header -->
<header style="margin-top: 120px; text-align: center; padding: 2rem;">
<h1 class="hover-target" style="font-size: clamp(2.5rem, 5vw, 4rem);"><span class="gradient-text">Protocol</span> Documentation</h1>
</header>
<main style="padding: 2rem;">
<div class="study-grid">
<div class="study-content reveal hover-target" data-tilt>
<h1 id="introduction">Introduction to Java</h1>
<p id="intro">Java is a popular programming language known for its simplicity, portability, and security. It is widely used for building mobile apps, web applications, and enterprise software.</p>
<button onclick="changeIntro()">Change Introduction</button>
<h2 id="basic-structure">Basic Structure of a Java Program</h2>
<p>A Java program consists of a class and a main method where execution starts.</p>
<pre><code id="codeSample">
// A simple Java program that prints "Hello, World!"
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!"); // Prints message to console
}
}
</code></pre>
<button onclick="changeCode()">Change Code Example</button>
<h2 id="variables-datatypes">Java Variables and Data Types</h2>
<p>Variables store data, and Java has different types for different values:</p>
<pre><code>
int number = 10; // Stores whole numbers
float pi = 3.14f; // Stores decimal numbers
char letter = 'A'; // Stores a single character
boolean isJavaFun = true; // Stores true or false values
String text = "Java is awesome!"; // Stores text
</code></pre>
<h2 id="operators">Java Operators</h2>
<p>Operators perform calculations or operations on values.</p>
<pre><code>
int a = 10, b = 5;
System.out.println(a + b); // Addition (10 + 5 = 15)
System.out.println(a - b); // Subtraction (10 - 5 = 5)
System.out.println(a * b); // Multiplication (10 * 5 = 50)
System.out.println(a / b); // Division (10 / 5 = 2)
System.out.println(a % b); // Modulus (remainder of 10/5 = 0)
</code></pre>
<h2 id="control-statements">Control Statements</h2>
<p>Control statements decide the flow of execution in a program.</p>
<pre><code>
int age = 18;
if (age >= 18) {
System.out.println("You are an adult.");
} else {
System.out.println("You are a minor.");
}
</code></pre>
<h2 id="loops">Loops in Java</h2>
<p>Loops allow executing a block of code multiple times.</p>
<button onclick="showLoop()">Show For Loop Example</button>
<pre id="loopExample" style="display:none;"><code>
for (int i = 1; i <= 5; i++) {
System.out.println("Iteration: " + i);
}
</code></pre>
<h2 id="functions">Functions (Methods) in Java</h2>
<p>Functions help reuse code and structure programs effectively.</p>
<pre><code>
public class Example {
public static void greet() {
System.out.println("Hello, Welcome to Java!");
}
public static void main(String[] args) {
greet(); // Calling the function
}
}
</code></pre>
<h2 id="oop">Object-Oriented Programming (OOP) in Java</h2>
<p>Java follows OOP principles, organizing code into objects and classes.</p>
<h3>1. Classes and Objects</h3>
<pre><code>
class Car {
String brand;
public void showBrand() {
System.out.println("Car brand: " + brand);
}
}
public class Main {
public static void main(String[] args) {
Car myCar = new Car();
myCar.brand = "Toyota";
myCar.showBrand();
}
}
</code></pre>
<h3>2. Inheritance</h3>
<pre><code>
class Animal {
void sound() {
System.out.println("Animals make sounds");
}
}
class Dog extends Animal {
void bark() {
System.out.println("Dog barks");
}
}
public class Main {
public static void main(String[] args) {
Dog myDog = new Dog();
myDog.sound();
myDog.bark();
}
}
</code></pre>
<h2 id="exception-handling">Exception Handling in Java</h2>
<p>Exception handling prevents program crashes due to errors.</p>
<pre><code>
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero!");
}
</code></pre>
<h2 id="getting-started">How to Start Coding in Java?</h2>
<ul>
<li>Install JDK and an IDE (like IntelliJ IDEA or Eclipse).</li>
<li>Write Java code in an IDE or a text editor.</li>
<li>Save the file with a <code>.java</code> extension.</li>
<li>Compile using <code>javac filename.java</code>.</li>
<li>Run using <code>java filename</code>.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>Java is a powerful, beginner-friendly language with vast applications. By mastering the basics, you can build strong programming skills.</p>\n </div>\n <aside class="study-sidebar reveal">\n<h2><i class="fas fa-list-alt"></i> Article Topics</h2>
<a href="#introduction"><i class="fas fa-book"></i> Introduction to Java</a>
<a href="#basic-structure"><i class="fas fa-book"></i> Basic Structure</a>
<a href="#variables-datatypes"><i class="fas fa-book"></i> Variables and Data Types</a>
<a href="#operators"><i class="fas fa-book"></i> Java Operators</a>
<a href="#control-statements"><i class="fas fa-book"></i> Control Statements</a>
<a href="#loops"><i class="fas fa-book"></i> Loops in Java</a>
<a href="#functions"><i class="fas fa-book"></i> Functions (Methods)</a>
<a href="#oop"><i class="fas fa-book"></i> Object-Oriented Programming (OOP)</a>
<a href="#exception-handling"><i class="fas fa-book"></i> Exception Handling</a>
<a href="#getting-started"><i class="fas fa-book"></i> Getting Started</a>
<a href="#conclusion"><i class="fas fa-book"></i> Conclusion</a>\n </aside>
</div>
</div>
</main>
<!-- Footer -->
<footer>
<div class="footer-grid reveal">
<div>
<h2 class="footer-logo">CodeLab<span style="color:var(--primary)">.ai</span></h2>
<p class="footer-p">The frontier of learning.</p>
</div>
</div>
<div style="text-align: center; border-top: 1px solid var(--glass-border); padding-top: 2rem; margin-top:2rem; color:var(--text-muted); font-size: 0.9rem;">
© 2026 CodeLab.ai Operations. All Rights Reserved.
</div>
</footer>
<script src="script.js"></script>
</body>
</html>