Friday, January 9, 2015

Java Data Type Program



Java boolean

public class JavaBooleanExample
{
public static void main(String[] args)
{
boolean = ;
boolean b1 = true;
boolean b2 = false;
boolean b3 = (10 > 2)? true:false;             
System.out.println("Value of boolean variable b1 is :" + b1);
System.out.println("Value of boolean variable b2 is :" + b2);
System.out.println("Value of boolean variable b3 is :" + b3);            
  }
 }

Java byte

public class JavaByteExample
public static void main(String[] args)
{
 byte = ;
 byte b1 = 100;
 byte b2 = 20;
System.out.println("Value of byte variable b1 is :" + b1);
System.out.println("Value of byte variable b1 is :" + b2);
   }
}
Java char
public class JavaCharExample
{
public static void main(String[] args)
{
char = ;
char ch1 = 'a';
char ch2 = 65;
System.out.println("Value of char variable ch1 is :" + ch1);   
System.out.println("Value of char variable ch2 is :" + ch2);             
   }
}

Java double

public class JavaDouble
          {
public static void main(String[] args)
                    {
double = ;
double d = 1232.44;
System.out.println("Value of double variable d is :" + d);               
   }
}

Java float

import java.util.*;
public class JavaFloatExample
{
public static void main(String[] args)
{
 float = ;
float f = 10.4f;
System.out.println("Value of float variable f is :" + f);                
   }
}
Java int
public class JavaInt
{
 public static void main(String[] args)
{
 int = ;
int i = 0;
int j = 100;
System.out.println("Value of int variable i is :" + i);
System.out.println("Value of int variable j is :" + j);
   }
}

No comments:

Post a Comment