FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 254 Ask New Question


On By


1 Answer


The following series of commands shows how to define primitive data types with values

jshell> byte byteVal = 127;
byteVal ==> 127

jshell> short shortVal = 32767;
shortVal ==> 32767

jshell> int intValue = 2147483647;
intValue ==> 2147483647

jshell> long longValue = 9223372036854775807L;
longValue ==> 9223372036854775807

jshell> float floatValue = 1.5F;
floatValue ==> 1.5

jshell> double doubleVaue = 12.678;
doubleVaue ==> 12.678

jshell> char charValue= 'f';
charValue ==> 'f'

jshell> boolean booleanValue = true;
booleanValue ==> true

jshell>

You can define Strings as shown in following example

jshell> String stringValue = "Foo";
stringValue ==> "Foo"

jshell>

You can access these variables with variable names on shell as shown in following example

jshell> System.out.println(stringValue);
Foo

jshell>
On By


Answer This Question


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News