Skip to content

Commit

Permalink
file renames
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshgaigawali committed Jul 17, 2024
1 parent 85b9157 commit 98fd87f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion HelloWorld.java → 01HelloWorld.java
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 !");
}
}
29 changes: 29 additions & 0 deletions 02JavaDataTypes.java
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).

}
}
21 changes: 0 additions & 21 deletions JavaDataTypes.java

This file was deleted.

25 changes: 13 additions & 12 deletions JavaTypeCasting.java
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);
}

}

0 comments on commit 98fd87f

Please sign in to comment.