Skip to content

Instantly share code, notes, and snippets.

@nikhilrajsingh
Created July 25, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilrajsingh/251e55a74b25f2d75478773f97f82fa9 to your computer and use it in GitHub Desktop.
Save nikhilrajsingh/251e55a74b25f2d75478773f97f82fa9 to your computer and use it in GitHub Desktop.
Task1
/* Author: Nikhil Raj Singh
* Section: K
*/
public class Task1 {
void dataTypeInfo() {
System.out.printf("%s %s %s %s\n", "Datatype", "Size in bits", "Size in bytes", "Range");
System.out.printf(" %s %d %d %s\n", "byte", Byte.SIZE, Byte.SIZE / 8, "From" + Byte.MIN_VALUE + "to" + Byte.MAX_VALUE);
System.out.printf(" %s %d %d %s\n", "short", Short.SIZE, Short.SIZE / 8, "From" + Short.MIN_VALUE + "to" + Short.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","int",Integer.SIZE,Integer.SIZE/8,"From"+Integer.MIN_VALUE+"to"+Integer.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","long",Long.SIZE,Long.SIZE/8,"From"+Long.MIN_VALUE+"to"+Long.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","float",Float.SIZE,Float.SIZE/8,"From " +Float.MIN_VALUE+"to " +Float.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","double",Double.SIZE,Double.SIZE/8,"From " +Double.MIN_VALUE+"to " +Double.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","char",Character.SIZE,Character.SIZE/8,"From"+Character.MIN_VALUE+"to"+Character.MAX_VALUE);
System.out.printf(" %s %d %d %s\n","boolean",1,1/8,"True or False");
}
}
class RunTask1{
public static void main(String[] args) {
Task1 run = new Task1();
run.dataTypeInfo();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment