Programming Tutorials

(追記) (追記ここまで)

Program using concept of byte long short and int in java

By: Java Samples in Java Tutorials on 2017年12月10日 [フレーム]

This simple java program describes how to use the different data types byte, short, int and long in Java.

public class DataTypes {
 byte a = 50;
 byte b = (byte) -80;
 short c = 1000;
 short d = -1500;
 int e = -15000;
 int f = 20000;
 long g = -1000L;
 long h = 2000L;
 byte addb() {
 return (byte) (a + b);
 }
 short adds() {
 return (short) (c + d);
 }
 int addi() {
 return e + f;
 }
 long addl() {
 return g + h;
 }
}
class MainClass {
 public static void main(String args[]) {
 DataTypes obj = new DataTypes();
 System.out.println("The byte Value is : " + obj.addb());
 System.out.println("The short Value is : " + obj.adds());
 System.out.println("The int Value is : " + obj.addi());
 System.out.println("The long Value is : " + obj.addl());
 }
}



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /