Basic variables defined as Java objects

Basic variables defined as Java objects: Types such as String, Integer, Double, Object, Long, Float, Boolean, Character, Vector


String variable is used for text printing. object type is variable. It is an object type defined in java using char variable type.

String name = "Bill";

String surname = "Gates";

String namesurname;

namesurname = name + " " + surname ;

System.out.println (namesurname);

output: Bill Gates


String name = new String ("Bill");

String surname = new String ("Gates");

String namesurname = new String ();

namesurname = name + " " + lastname;

System.out.println (namesurname);

output: Bill Gates



Integer i;

i=new Integer(3);

veya Integer i=new Integer(3);

Convert string to int

String s="15";

Int x=Integer.parseInt(s);

Convert integer value to string

int x=3;

String s=Integer.toString(x);



Double x;

x=new Double(3.66e5)


Double x=new Double(3.66e5)

Convert String to Double

String s="15.66e-3";

Double x=new Double(s);

Convert Double value to double value

double x;

Double y=new Double(15.66e-3);


Convert a Double value to an int value

int x;

Double y=new Double(15.66e-3);


Tagged In:

Software developer

26 Total Posts