-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85b9157
commit 98fd87f
Showing
4 changed files
with
43 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello! World."); | ||
System.out.println("Hello, World !"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class JavaDataTypes { | ||
|
||
public static void main(String args[]) { | ||
|
||
boolean bool = true; // Holds values "True" or "False". | ||
|
||
byte b = 127; // Ranges from -128 to 127. | ||
|
||
short s = 32_767; // Its value-range lies between -32,768 to 32,767. | ||
|
||
int i = 38299; /* | ||
* Its value-range lies between - 2,147,483,648 (-2^31) to 2,147,483,647 | ||
* (2^31-1). | ||
*/ | ||
|
||
long l = 89403938849383l; /* | ||
* Its value-range lies between -9,223,372,036,854,775,808(-2^63) to | ||
* 9,223,372,036,854,775,807(2^63 -1). | ||
*/ | ||
|
||
float f = 256.5f; // 32-bit | ||
|
||
double d = 3489.78; // 64-bit | ||
|
||
char c = '$'; // 16-bit Unicode character Its value-range lies between '\u0000' (or 0) to | ||
// '\uffff' (or 65,535 inclusive). | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
class JavaTypeCasting{ | ||
public static void main(String args[]){ | ||
class JavaTypeCasting { | ||
public static void main(String args[]) { | ||
|
||
byte b1=10; | ||
byte b2=30; | ||
int a = b2; //Implicite type casting or conversion. | ||
byte b1 = 10; | ||
byte b2 = 30; | ||
int a = b2; // Widening || Implicite type casting or conversion. | ||
|
||
System.out.println(a); | ||
System.out.println(a); | ||
|
||
float f=1729.89f; | ||
int i=(int) f; //Explicite type casting. | ||
float f = 1729.89f; | ||
int i = (int) f; // Narrowing || Explicite type casting. | ||
|
||
System.out.println(i); | ||
System.out.println(i); | ||
|
||
int result= b1*b2; //Type promotion. (As the multiplication operation gives result beyond the range of byte hence it stores it into int.) | ||
int result = b1 * b2; // Type promotion. (As the multiplication operation gives result beyond the | ||
// range of byte hence it stores it into int.) | ||
|
||
System.out.println(result); | ||
} | ||
System.out.println(result); | ||
} | ||
|
||
} |