-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.java
More file actions
37 lines (32 loc) · 1.21 KB
/
index.java
File metadata and controls
37 lines (32 loc) · 1.21 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
import java.util.*;
public class index {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
System.out.println("Hello " + name);
int a = 10;
String b = "Hello";
float c = 37.5f;
double d = 10.5;
//type conversion
// this is the method use to give the value of one data type to another data type having highter memory is called type conversion.
int e = 10;
float f = e; //implicit type conversion
//type casting
// this is the method use to give the value of one data type to another data type having lower memory is called type casting.
float g = 10.5f;
int h = (int)g; //explicit type casting
//type promotion
// this is the method use to give the value of one data type to another data type having int memory if it is short,byte, int (largest possible varible) is called type promotion.
byte i = 10;
byte j = 20;
int k = i + j; //type promotion
System.out.println(k);
System.out.println(a);
System.out.println(b);
System.out.println(c * d);
System.out.println("the value is " + a);
System.out.println("the value is " + f);
System.out.println("the value is " + h);
}
}