Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a Java Program to convert int type variables to long
PROGRAM: Java Program to convert int type variables to long
/*Java Program to convert int type variables to long*/
1: Java Program to Convert int to long using Typecasting
class Main {
public static void main(String[] args) {
// create int variables
int a = 25;
int b = 34;
// convert int into long
// using typecasting
long c = a;
long d = b;
System.out.println(c); // 25
System.out.println(d); // 34
}
}
2: Java Program to Convert int into object of Long using valueof()
class Main {
public static void main(String[] args) {
// create int variables
int a = 251;
// convert to an object of Long
// using valueOf()
Long obj = Long.valueOf(a);
System.out.println(obj); // 251
}
}