-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnine.java
More file actions
16 lines (16 loc) · 717 Bytes
/
nine.java
File metadata and controls
16 lines (16 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//Write a program to show the use of typecasting
import java.util.Scanner;
public class ningth {
public static void main(String[] args) {
int intVal = 100;
double doubleVal = intVal;
System.out.println("Implicit Typecasting:");
System.out.println("Integer value: " + intVal);
System.out.println("Converted to double: " + doubleVal);
double originalDouble = 123.456;
int castedInt = (int) originalDouble;
System.out.println("\nExplicit Typecasting:");
System.out.println("Original double value: " + originalDouble);
System.out.println("Converted to integer: " + castedInt);
}
}