Skip to content

Commit 383021d

Browse files
committed
Working with Long and Double
1 parent 5b24056 commit 383021d

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

Task-08/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
6+
### Eclipse ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
bin/
15+
!**/src/main/**/bin/
16+
!**/src/test/**/bin/
17+
18+
### NetBeans ###
19+
/nbproject/private/
20+
/nbbuild/
21+
/dist/
22+
/nbdist/
23+
/.nb-gradle/
24+
25+
### VS Code ###
26+
.vscode/
27+
28+
### Mac OS ###
29+
.DS_Store

Task-08/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Task-08/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Task-08/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Task-08/Task-08.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

Task-08/src/Main.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//Exercise 8: Working with Long and Double
2+
//8. Task: Declare a long variable with the value 10000000000L and a double variable with a value of your choice.
3+
// Print both values. Demonstrate why adding L is important for long data types.
4+
//o Expected Output:
5+
//Long value: 10000000000
6+
//Double value: [Your Double Value]
7+
8+
public class Main {
9+
public static void main(String[] args) {
10+
// Correct usage with L suffix
11+
long longVarWithL = 10000000000L; // This will work
12+
double doubleVar = 122312.232; // Example double value
13+
System.out.println("Long value with L: " + longVarWithL);
14+
System.out.println("Double value: " + doubleVar);
15+
// Demonstrating the incorrect way without L suffix
16+
// long longVarWithoutL = 10000000000; // This will cause a compilation error
17+
18+
// To illustrate the error, let's just show it as a comment:
19+
System.out.println("If we try to do this without L:");
20+
System.out.println("long longVarWithoutL = 10000000000; // This causes a compilation error");
21+
}
22+
}

0 commit comments

Comments
 (0)