This is a Java Program to Convert Long Values into Byte.
Enter any long integer as an input. After that we convert the given long integer into byte using explicit type casting.
Here is the source code of the Java Program to Convert Long Values into Byte. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Long_Byte
{
public static void main(String[] args)
{
long a;
byte b;
Scanner s = new Scanner(System.in);
System.out.print("Enter any long value:");
a = s.nextLong();
b = (byte) a;
System.out.println("Conversion into byte:"+b);
}
}
Output:
$ javac Long_Byte.java $ java Long_Byte Enter any long value:12548 Conversion into byte:4
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
If you find any mistake above, kindly email to [email protected]Related Posts:
- Check Java Books
- Check Programming Books
- Practice Information Technology MCQs
- Practice Programming MCQs
- Apply for Java Internship