Created
July 20, 2020 14:51
-
-
Save nikhilrajsingh/1b5c77b5f35ba7008fbe78e4519b3818 to your computer and use it in GitHub Desktop.
Task 2 - Create a program in Java to declare, initialize and use local variables of all the primitive data types in Java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//created by Nikhil Raj Singh | |
//section K | |
//Task 2 - Create a program in Java to declare, initialize and use local variables of all the primitive data types in Java. | |
public class DataTypes { | |
byte Byte; short Short;int Int;long Long;float Float;double Double; char Character;boolean Boolean; | |
void integerType(){ | |
Byte = 1; | |
Short = 12; | |
Int = -23; | |
Long = 2L; | |
} | |
void floatingPoint(){ | |
Float = 3.14f; | |
Double = 2.4e100d; | |
} | |
void characterValue(){ | |
Character = 'a'; | |
} | |
void print() { | |
integerType(); | |
System.out.println("byte Type=" + Byte); | |
System.out.println("short Type=" + Short); | |
System.out.println("int Type=" + Int); | |
System.out.println("long Type=" + Long); | |
floatingPoint(); | |
System.out.println("float Type=" + Float); | |
System.out.println("double Type=" + Double); | |
characterValue(); | |
System.out.println("char Type=" + Character); | |
System.out.println("boolean Type=" + Boolean); | |
} | |
} | |
class execute{ | |
public static void main(String[] args) { | |
DataTypes run= new DataTypes(); | |
run.print(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment