Open zhamri opened 5 years ago
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\user>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell>
jshell> Ng Ke Rong | Error: | ';' expected | Ng Ke Rong; | ^
jshell> "Ng Ke Rong" $1 ==> "Ng Ke Rong"
jshell> /exit | Goodbye
C:\Users\user>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> Ng Ke Rong" | Error: | ';' expected | Ng Ke Rong" | ^
jshell> "Ng Ke Rong" $1 ==> "Ng Ke Rong" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "NgKeRong#tag" $3 ==> "NgKeRong#tag" | created scratch variable $3 : String
jshell> 'Ng Ke Rong' | Error: | unclosed character literal | 'Ng Ke Rong' | ^ | Error: | unclosed character literal | 'Ng Ke Rong' | ^
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag"
jshell> String name = "Ng Ke Rong" name ==> "Ng Ke Rong" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag" | String name = "Ng Ke Rong" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "Ng Ke RongUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag" | String name = "Ng Ke Rong" | String $name = "SOC" | boolean $6 = false | String $7 = "Ng Ke RongUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age>price $12 ==> false | created scratch variable $12 : boolean
jshell> age != price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag" | String name = "Ng Ke Rong" | String $name = "SOC" | boolean $6 = false | String $7 = "Ng Ke RongUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "Ng Ke Rong" 2 : "Universiti Utara Malaysia" 3 : "NgKeRong#tag" 4 : String name = "Ng Ke Rong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age != price
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag" | String name = "Ng Ke Rong" | String $name = "SOC" | boolean $6 = false | String $7 = "Ng Ke RongUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[] args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "Ng Ke Rong" 2 : "Universiti Utara Malaysia" 3 : "NgKeRong#tag" 4 : String name = "Ng Ke Rong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age != price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "Ng Ke Rong" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgKeRong#tag" | String name = "Ng Ke Rong" | String $name = "SOC" | boolean $6 = false | String $7 = "Ng Ke RongUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /methods | void main(String[])
jshell> /list
1 : "Ng Ke Rong" 2 : "Universiti Utara Malaysia" 3 : "NgKeRong#tag" 4 : String name = "Ng Ke Rong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age != price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /list
1 : "Ng Ke Rong" 2 : "Universiti Utara Malaysia" 3 : "NgKeRong#tag" 4 : String name = "Ng Ke Rong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age != price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 2
jshell> /edit 15 | created method main()
jshell> /list
1 : "Ng Ke Rong" 2 : "Universiti Utara Malaysia" 3 : "NgKeRong#tag" 4 : String name = "Ng Ke Rong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age != price 15 : public void main(String[] args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello Ng Ke Rong UUM"); }
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\USER>java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
C:\Users\USER>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> fangman | Error: | cannot find symbol | symbol: variable fangman | fangman | ^-----^
jshell> "fangman" $1 ==> "fangman"
jshell> /exit | Goodbye
C:\Users\USER>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> fangman | Error: | cannot find symbol | symbol: variable fangman | fangman | ^-----^
jshell> "fangman" $1 ==> "fangman" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "fangman#tag" $3 ==> "fangman#tag" | created scratch variable $3 : String
jshell> 'fangman' | Error: | unclosed character literal | 'fangman' | ^ | Error: | unclosed character literal | 'fangman' | ^ | Error: | reached end of file while parsing | 'fangman' | ^
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag"
jshell> String name = "wong fang man" name ==> "wong fang man" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC"
jshell> s1==s2 | Error: | cannot find symbol | symbol: variable s1 | s1==s2 | ^^ | Error: | cannot find symbol | symbol: variable s2 | s1==s2 | ^^
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1 + $2 $7 ==> "fangmanUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC" | boolean $6 = false | String $7 = "fangmanUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC" | boolean $6 = false | String $7 = "fangmanUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> age != price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC" | boolean $6 = false | String $7 = "fangmanUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "fangman" 2 : "Universiti Utara Malaysia" 3 : "fangman#tag" 4 : String name = "wong fang man"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC" | boolean $6 = false | String $7 = "fangmanUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /list
1 : "fangman" 2 : "Universiti Utara Malaysia" 3 : "fangman#tag" 4 : String name = "wong fang man"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 15 : public void main(){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "fangman" | String $2 = "Universiti Utara Malaysia" | String $3 = "fangman#tag" | String name = "wong fang man" | String $name = "SOC" | boolean $6 = false | String $7 = "fangmanUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /method | void main(String[]) | void main()
jshell> /list
1 : "fangman" 2 : "Universiti Utara Malaysia" 3 : "fangman#tag" 4 : String name = "wong fang man"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 15 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /list
1 : "fangman" 2 : "Universiti Utara Malaysia" 3 : "fangman#tag" 4 : String name = "wong fang man"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello fangman uum"); }
jshell> /edit 2
jshell> /list
1 : "fangman" 2 : "Universiti Utara Malaysia" 3 : "fangman#tag" 4 : String name = "wong fang man"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello fangman uum"); }
| String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC"
jshell> $1 $1 ==> "ahmad" | value of $1 : String
jshell> $1 + $2 $6 ==> "ahmaduniversiti utara malaysia" | created scratch variable $6 : String
jshell> int age = 20 age ==> 20 | created variable age : int
jshell> /vars | String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC" | String $6 = "ahmaduniversiti utara malaysia" | int age = 20
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> /vars | String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC" | String $6 = "ahmaduniversiti utara malaysia" | int age = 20 | int $8 = 15
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> age + price | Error: | cannot find symbol | symbol: variable price | age + price | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> age + price $10 ==> 70.99000000000001 | created scratch variable $10 : double
jshell> age>price $11 ==> false | created scratch variable $11 : boolean
jshell> age !=price $12 ==> true | created scratch variable $12 : boolean
jshell> /vars | String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC" | String $6 = "ahmaduniversiti utara malaysia" | int age = 20 | int $8 = 15 | double price = 50.99 | double $10 = 70.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||
intro | ||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||
keys | ||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||
id | ||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||
context | ||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /re |
set | rerun | a description of ways to re-evaluate previously entered snippets
jshell> /list
1 : "ahmad" 2 : "universiti utara malaysia" 3 : String name = "ahmad"; 4 : String $name = "SOC"; 5 : $1 6 : $1 + $2 7 : int age = 20; 8 : 7+8 9 : double price = 50.99; 10 : age + price 11 : age>price 12 : age !=price
jshell> /vars | String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC" | String $6 = "ahmaduniversiti utara malaysia" | int age = 20 | int $8 = 15 | double price = 50.99 | double $10 = 70.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> public static void main(String[] args){ ...> system.out.println("Hello World"); ...> } | Error: | package system does not exist | system.out.println("Hello World"); | ^--------^ | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^
jshell> public void main(String[] args){ ...> system.out.printiln(Hello World); ...> } | Error: | ')' expected | system.out.printiln(Hello World); | ^ | Error: | not a statement | system.out.printiln(Hello World); | ^---^ | Error: | ';' expected | system.out.printiln(Hello World); | ^
jshell> public void main(String[] args){ ...> system.out.println("Hello World"); ...> } | Error: | package system does not exist | system.out.println("Hello World"); | ^--------^
jshell> public void main(String[] args){ ...> System.out.println("Hello World"); ...> } | created method main(String[])
jshell> /vars | String $1 = "ahmad" | String $2 = "universiti utara malaysia" | String name = "ahmad" | String $name = "SOC" | String $6 = "ahmaduniversiti utara malaysia" | int age = 20 | int $8 = 15 | double price = 50.99 | double $10 = 70.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> /list
1 : "ahmad" 2 : "universiti utara malaysia" 3 : String name = "ahmad"; 4 : String $name = "SOC"; 5 : $1 6 : $1 + $2 7 : int age = 20; 8 : 7+8 9 : double price = 50.99; 10 : age + price 11 : age>price 12 : age !=price 13 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "ahmad" 2 : "universiti utara malaysia" 3 : String name = "ahmad"; 4 : String $name = "SOC"; 5 : $1 6 : $1 + $2 7 : int age = 20; 8 : 7+8 9 : double price = 50.99; 10 : age + price 11 : age>price 12 : age !=price 14 : public static void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 14
jshell> /edit 2 $15 ==> "universiti utara malaysia Uum" | created scratch variable $15 : String
jshell> /list
1 : "ahmad" 2 : "universiti utara malaysia" 3 : String name = "ahmad"; 4 : String $name = "SOC"; 5 : $1 6 : $1 + $2 7 : int age = 20; 8 : 7+8 9 : double price = 50.99; 10 : age + price 11 : age>price 12 : age !=price 14 : public static void main(String[] args){ System.out.println("Hello World"); } 15 : "universiti utara malaysia Uum";
jshell>
Microsoft Windows [Version 10.0.18362.239] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Farha>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\Farha>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> Farha | Error: | cannot find symbol | symbol: variable Farha | Farha | ^---^
jshell> "Farha" $1 ==> "Farha"
jshell> /exit | Goodbye
C:\Users\Farha>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "Farha" $1 ==> "Farha"
jshell> jshell -v | Error: | cannot find symbol | symbol: variable jshell | jshell -v | ^----^ | Error: | cannot find symbol | symbol: variable v | jshell -v | ^
jshell> /exit | Goodbye
C:\Users\Farha>jshell -v | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "Farha" $1 ==> "Farha" | created scratch variable $1 : String
jshell> /vars | String $1 = "Farha"
jshell> "3verything" $2 ==> "3verything" | created scratch variable $2 : String
jshell> "Universiti Utara Malaysia" $3 ==> "Universiti Utara Malaysia" | created scratch variable $3 : String
jshell> String name = "Farha" name ==> "Farha" | created variable name : String
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha"
jshell> String $name = "Arif Farhan" $name ==> "Arif Farhan" | created variable $name : String
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1 + $2 $7 ==> "Farha3verything" | created scratch variable $7 : String
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything"
jshell> $2-$3 | Error: | bad operand types for binary operator '-' | first type: java.lang.String | second type: java.lang.String | $2-$3 | ^---^
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything"
jshell> 69 + 96 $8 ==> 165 | created scratch variable $8 : int
jshell> int age = 20 age ==> 20 | created variable age : int
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20
jshell> double price = 99.99 price ==> 99.99 | created variable price : double
jshell> age + price $11 ==> 119.99 | created scratch variable $11 : double
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99
/vars
jshell> age != price $12 ==> true | created scratch variable $12 : boolean
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99 | boolean $12 = true
jshell> age == price $13 ==> false | created scratch variable $13 : boolean
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99 | boolean $12 = true | boolean $13 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "Farha" 2 : "3verything" 3 : "Universiti Utara Malaysia" 4 : String name = "Farha"; 5 : String $name = "Arif Farhan"; 6 : $1==$2 7 : $1 + $2 8 : 69 + 96 9 : int age = 20; 10 : double price = 99.99; 11 : age + price 12 : age != price 13 : age == price
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99 | boolean $12 = true | boolean $13 = false
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99 | boolean $12 = true | boolean $13 = false
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> /list
1 : "Farha" 2 : "3verything" 3 : "Universiti Utara Malaysia" 4 : String name = "Farha"; 5 : String $name = "Arif Farhan"; 6 : $1==$2 7 : $1 + $2 8 : 69 + 96 9 : int age = 20; 10 : double price = 99.99; 11 : age + price 12 : age != price 13 : age == price 14 : public void main(){ System.out.println("Hello World"); } 15 : public static void main(String[] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "Farha" | String $2 = "3verything" | String $3 = "Universiti Utara Malaysia" | String name = "Farha" | String $name = "Arif Farhan" | boolean $6 = false | String $7 = "Farha3verything" | int $8 = 165 | int age = 20 | double price = 99.99 | double $11 = 119.99 | boolean $12 = true | boolean $13 = false
jshell> /method | void main() | void main(String[])
jshell> /list
1 : "Farha" 2 : "3verything" 3 : "Universiti Utara Malaysia" 4 : String name = "Farha"; 5 : String $name = "Arif Farhan"; 6 : $1==$2 7 : $1 + $2 8 : 69 + 96 9 : int age = 20; 10 : double price = 99.99; 11 : age + price 12 : age != price 13 : age == price 14 : public void main(){ System.out.println("Hello World"); } 15 : public static void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 14 | modified method main() | update overwrote method main()
jshell> /list
1 : "Farha" 2 : "3verything" 3 : "Universiti Utara Malaysia" 4 : String name = "Farha"; 5 : String $name = "Arif Farhan"; 6 : $1==$2 7 : $1 + $2 8 : 69 + 96 9 : int age = 20; 10 : double price = 99.99; 11 : age + price 12 : age != price 13 : age == price 15 : public static void main(String[] args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello World DIO"); }
jshell> /edit 2
jshell> /list
1 : "Farha" 2 : "3verything" 3 : "Universiti Utara Malaysia" 4 : String name = "Farha"; 5 : String $name = "Arif Farhan"; 6 : $1==$2 7 : $1 + $2 8 : 69 + 96 9 : int age = 20; 10 : double price = 99.99; 11 : age + price 12 : age != price 13 : age == price 15 : public static void main(String[] args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello World DIO"); }
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Faiz>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\Faiz>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> /vars
jshell> "faiz" $1 ==> "faiz"
jshell> "university" $2 ==> "university"
jshell> /vars | String $1 = "faiz" | String $2 = "university"
jshell> int $age=12 $age ==> 12
jshell> int $age=23 $age ==> 23
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "faiz" 2 : "university" 4 : int $age=23;
jshell> /vars | String $1 = "faiz" | String $2 = "university" | int $age = 23
jshell> public.void.main{ ...> jshell> /vars ...> ...> jshell> "faiz" ...> $1 ==> "faiz" ...> ...> jshell> "university" ...> $2 ==> "university" ...> ...> jshell> /vars ...> | String $1 = "faiz" ...> | String $2 = "university" ...> ...> jshell> int $age=12 ...> $age ==> 12 ...> ...> jshell> int $age=23 ...> $age ==> 23 ...>
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\anisn> C:\Users\anisn>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\anisn>jshell> The syntax of the command is incorrect.
C:\Users\anisn>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> anis | Error: | cannot find symbol | symbol: variable anis | anis | ^--^
jshell> "anis" $1 ==> "anis"
jshell> /exit | Goodbye
C:\Users\anisn>jshell -v | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "anis" $1 ==> "anis" | created scratch variable $1 : String
jshell> /vars | String $1 = "anis"
jshell> String name = "anis nabilah" name ==> "anis nabilah" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell>
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC"
jshell> $1==$2 | Error: | cannot find symbol | symbol: variable $2 | $1==$2 | ^^
jshell> "universiti utara malaysia" $4 ==> "universiti utara malaysia" | created scratch variable $4 : String
jshell> $1==$4 $5 ==> false | created scratch variable $5 : boolean
jshell> $1 + $4 $6 ==> "anisuniversiti utara malaysia" | created scratch variable $6 : String
jshell> $<$4 | Error: | cannot find symbol | symbol: variable $ | $<$4 | ^
jshell> $1<$4 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$4 | ^---^
jshell> 7+8 $7 ==> 15 | created scratch variable $7 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell>
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21 | double price = 50.99
jshell> age + price $10 ==> 71.99000000000001 | created scratch variable $10 : double
jshell> age > price $11 ==> false | created scratch variable $11 : boolean
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false
jshell>
jshell> age != price $12 ==> true | created scratch variable $12 : boolean
jshell>
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false | boolean $12 = true
jshell>
jshell>
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell>
jshell> /list
1 : "anis" 2 : String name = "anis nabilah"; 3 : String $name = "SOC"; 4 : "universiti utara malaysia" 5 : $1==$4 6 : $1 + $4 7 : 7+8 8 : int age = 21; 9 : double price = 50.99; 10 : age + price 11 : age > price 12 : age != price
jshell>
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> public static void main(String[] args){ ...> System.out.printIn(Hello World"); | Error: | ')' expected | System.out.printIn(Hello World"); | ^ | Error: | unclosed string literal | System.out.printIn(Hello World"); | ^ | Error: | not a statement | System.out.printIn(Hello World"); | ^---^ | Error: | reached end of file while parsing | System.out.printIn(Hello World"); | ^
jshell>
jshell> public void main(){ ...> System.out.printIn("Hello World"); ...> } | Error: | cannot find symbol | symbol: method printIn(java.lang.String) | System.out.printIn("Hello World"); | ^----------------^
jshell> /vars | String $1 = "anis" | String name = "anis nabilah" | String $name = "SOC" | String $4 = "universiti utara malaysia" | boolean $5 = false | String $6 = "anisuniversiti utara malaysia" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> /list
1 : "anis" 2 : String name = "anis nabilah"; 3 : String $name = "SOC"; 4 : "universiti utara malaysia" 5 : $1==$4 6 : $1 + $4 7 : 7+8 8 : int age = 21; 9 : double price = 50.99; 10 : age + price 11 : age > price 12 : age != price
jshell> public static void main(String[] args){ ...> System.out.printIn("Hello World"); ...> } | Error: | cannot find symbol | symbol: method printIn(java.lang.String) | System.out.printIn("Hello World"); | ^----------------^ | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^
jshell>
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /methods
jshell> /methods
jshell> /edit
jshell> jj NKJKFJOOPPDJCKF/GGKJL | Error: | ';' expected | jj NKJKFJOOPPDJCKF/GGKJL | ^
jshell> /edit 2 name ==> "anis nabilah sapawi" | modified variable name : String | update overwrote variable name : String
jshell> /list
1 : "anis" 3 : String $name = "SOC"; 4 : "universiti utara malaysia" 5 : $1==$4 6 : $1 + $4 7 : 7+8 8 : int age = 21; 9 : double price = 50.99; 10 : age + price 11 : age > price 12 : age != price 13 : String name = "anis nabilah sapawi";
jshell> public void main (){ ...> System.out.printIn("Hello World"); ...> } | Error: | cannot find symbol | symbol: method printIn(java.lang.String) | System.out.printIn("Hello World"); | ^----------------^
jshell> /method
jshell> /list
1 : "anis" 3 : String $name = "SOC"; 4 : "universiti utara malaysia" 5 : $1==$4 6 : $1 + $4 7 : 7+8 8 : int age = 21; 9 : double price = 50.99; 10 : age + price 11 : age > price 12 : age != price 13 : String name = "anis nabilah sapawi";
jshell> System.out.printIn("Hello World"); | Error: | cannot find symbol | symbol: method printIn(java.lang.String) | System.out.printIn("Hello World"); | ^----------------^
jshell> ...> } System.out.printIn("Hello World"); | Error: | illegal start of expression | ...> } System.out.printIn("Hello World"); | ^
jshell> ...> } System.out.printIn("Hello World"); | Error: | illegal start of expression | ...> } System.out.printIn("Hello World"); | ^
jshell> ...> }
Microsoft Windows [Version 10.0.17134.590] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\user>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\user>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> haslinda | Error: | cannot find symbol | symbol: variable haslinda | haslinda | ^------^
jshell> "haslinda" $1 ==> "haslinda"
jshell> /vars | String $1 = "haslinda"
jshell> 'Universiti Utara Malaysia" | Error: | unclosed character literal | 'Universiti Utara Malaysia" | ^ | Error: | unclosed string literal | 'Universiti Utara Malaysia" | ^
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia"
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia"
jshell> "haslinda#tag" $3 ==> "haslinda#tag"
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag"
jshell> String nama = "nur haslinda" nama ==> "nur haslinda"
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda"
jshell> String "SOC" | Error: | ';' expected | String "SOC" | ^ | Error: | cannot find symbol | symbol: variable String | String "SOC" | ^----^
jshell> String $name = "SOC" $name ==> "SOC"
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC"
jshell> $1==$2 $6 ==> false
jshell> $1 + $2 $7 ==> "haslindaUniversiti Utara Malaysia"
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15
jshell> intr age = 21 | Error: | cannot find symbol | symbol: class intr | intr age = 21; | ^--^
jshell> int age = 21 age ==> 21
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> double price = 50.99 price ==> 50.99
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001
jshell> age > price $12 ==> false
jshell> age ! = price | Error: | ';' expected | age ! = price | ^ | Error: | not a statement | age ! = price | ^---^
jshell> age != price $13 ==> true
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell>
jshell>
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell>
jshell> /list
1 : "haslinda" 2 : "Universiti Utara Malaysia" 3 : "haslinda#tag" 4 : String nama = "nur haslinda"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[] args){ ...> Sysytem.out.printIn("Hello World");} | Error: | package Sysytem does not exist | Sysytem.out.printIn("Hello World");} | ^---------^ | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^
jshell> public void main () { ...> System.out.printIn(Hello World); ...> } | Error: | ')' expected | System.out.printIn(Hello World); | ^ | Error: | not a statement | System.out.printIn(Hello World); | ^---^ | Error: | ';' expected | System.out.printIn(Hello World); | ^
jshell> /method
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /method
jshell> /methods
jshell> /list
1 : "haslinda" 2 : "Universiti Utara Malaysia" 3 : "haslinda#tag" 4 : String nama = "nur haslinda"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /edit 15 | No snippet with ID: 15
jshell> /edit $14 ==> "haslinda UUM"
jshell> /vars | String $1 = "haslinda" | String $2 = "Universiti Utara Malaysia" | String $3 = "haslinda#tag" | String nama = "nur haslinda" | String $name = "SOC" | boolean $6 = false | String $7 = "haslindaUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true | String $14 = "haslinda UUM"
Microsoft Windows [Version 10.0.17134.648] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\saya>java -version java version "12.0.2" 2019-07-16 Java(TM) SE Runtime Environment (build 12.0.2+10) Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\saya>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> anis | Error: | cannot find symbol | symbol: variable anis | anis | ^--^
jshell> "anis" $1 ==> "anis"
jshell> /exit | Goodbye
C:\Users\saya>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> "anis" $1 ==> "anis" | created scratch variable $1 : String
jshell> /vars | String $1 = "anis"
jshell> "anis adila" $2 ==> "anis adila" | created scratch variable $2 : String
jshell>
jshell> $1=$2 $1 ==> "anis adila" | assigned to $1 : String
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | double price = 50.99
jshell> String $name = "soc" $name ==> "soc" | created variable $name : String
jshell> $1=$2 $1 ==> "anis adila" | assigned to $1 : String
jshell> $1==$2 $7 ==> true | created scratch variable $7 : boolean
jshell> $1 + $2 $8 ==> "anis adilaanis adila" | created scratch variable $8 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7 + 8 $9 ==> 15 | created scratch variable $9 : int
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | double price = 50.99 | String $name = "soc" | boolean $7 = true | String $8 = "anis adilaanis adila" | int $9 = 15
jshell> int age = 20 age ==> 20 | created variable age : int
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^ | update overwrote variable price : double
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | String $name = "soc" | boolean $7 = true | String $8 = "anis adilaanis adila" | int $9 = 15 | int age = 20
jshell> age + price | Error: | cannot find symbol | symbol: variable price | age + price | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> age + price $12 ==> 70.99000000000001 | created scratch variable $12 : double
jshell> age > price $13 ==> false | created scratch variable $13 : boolean
jshell> age != price $14 ==> true | created scratch variable $14 : boolean
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | String $name = "soc" | boolean $7 = true | String $8 = "anis adilaanis adila" | int $9 = 15 | int age = 20 | double price = 50.99 | double $12 = 70.99000000000001 | boolean $13 = false | boolean $14 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "anis" 2 : "anis adila" 3 : $1=$2 5 : String $name = "soc"; 6 : $1=$2 7 : $1==$2 8 : $1 + $2 9 : 7 + 8 10 : int age = 20; 11 : double price = 50.99; 12 : age + price 13 : age > price 14 : age != price
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | String $name = "soc" | boolean $7 = true | String $8 = "anis adilaanis adila" | int $9 = 15 | int age = 20 | double price = 50.99 | double $12 = 70.99000000000001 | boolean $13 = false | boolean $14 = true
jshell> public static void main(atring[] args){ ...> System.out.println("Hello World") ...> } | Error: | ';' expected | System.out.println("Hello World") | ^
jshell> public void main (){ ...> System.out.println("Hello World") ...> } | Error: | ';' expected | System.out.println("Hello World") | ^
jshell> /list
1 : "anis" 2 : "anis adila" 3 : $1=$2 5 : String $name = "soc"; 6 : $1=$2 7 : $1==$2 8 : $1 + $2 9 : 7 + 8 10 : int age = 20; 11 : double price = 50.99; 12 : age + price 13 : age > price 14 : age != price
jshell> /vars | String $1 = "anis adila" | String $2 = "anis adila" | String $name = "soc" | boolean $7 = true | String $8 = "anis adilaanis adila" | int $9 = 15 | int age = 20 | double price = 50.99 | double $12 = 70.99000000000001 | boolean $13 = false | boolean $14 = true
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /list
1 : "anis" 2 : "anis adila" 3 : $1=$2 5 : String $name = "soc"; 6 : $1=$2 7 : $1==$2 8 : $1 + $2 9 : 7 + 8 10 : int age = 20; 11 : double price = 50.99; 12 : age + price 13 : age > price 14 : age != price 15 : public void main(){ System.out.println("Hello World"); }
jshell> public static void main(String[] args){ ...> System.out.println("Hello World") ...> } | Error: | ';' expected | System.out.println("Hello World") | ^
jshell> public statis void(String[] args){ ...> System.out.println("Hello World"); ...> } | Error: | ';' expected | public statis void(String[] args){ | ^ | Error: | illegal start of expression | public statis void(String[] args){ | ^--^ | Error: | ';' expected | public statis void(String[] args){ | ^ | Error: | ';' expected | public statis void(String[] args){ | ^ | Error: | cannot find symbol | symbol: variable statis | public statis void(String[] args){ | ^----^
jshell> /method | void main()
jshell> /methods | void main()
jshell> /methods | void main()
jshell> /edit 2
jshell> /list
1 : "anis" 2 : "anis adila" 3 : $1=$2 5 : String $name = "soc"; 6 : $1=$2 7 : $1==$2 8 : $1 + $2 9 : 7 + 8 10 : int age = 20; 11 : double price = 50.99; 12 : age + price 13 : age > price 14 : age != price 15 : public void main(){ System.out.println("Hello World"); }
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Auntie Goh>java -version java version "12.0.2" 2019-07-16 Java(TM) SE Runtime Environment (build 12.0.2+10) Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\Auntie Goh>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> yoncing | Error: | cannot find symbol | symbol: variable yoncing | yoncing | ^-----^
jshell> "yoncing" $1 ==> "yoncing"
jshell> /exit | Goodbye
C:\Users\Auntie Goh>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> "yoncing" $1 ==> "yoncing" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "yoncing#tag"/vars | Error: | cannot find symbol | symbol: variable vars | "yoncing#tag"/vars | ^--^
jshell> "yoncing#tag" $3 ==> "yoncing#tag" | created scratch variable $3 : String
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag"
jshell> String name="yoncing" name ==> "yoncing" | created variable name : String
jshell> String $name="SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "yoncingUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age=21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price=50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price=50.99; | ^---^
jshell> duoble price=50.99 | Error: | cannot find symbol | symbol: class duoble | duoble price=50.99; | ^----^
jshell> double price=50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age+price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age>price $12 ==> false | created scratch variable $12 : boolean
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false
jshell> age!=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "yoncing" 2 : "Universiti Utara Malaysia" 3 : "yoncing#tag" 4 : String name="yoncing"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /vars | String $1 = "yoncing" | String $2 = "Universiti Utara Malaysia" | String $3 = "yoncing#tag" | String name = "yoncing" | String $name = "SOC" | boolean $6 = false | String $7 = "yoncingUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /list
1 : "yoncing" 2 : "Universiti Utara Malaysia" 3 : "yoncing#tag" 4 : String name="yoncing"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 15 : public void main(){ System.out.println("Hello World"); }
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /methods | void main(String[]) | void main()
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /edit 2 jshell> /list
1 : "yoncing" 2 : "Universiti Utara Malaysia" 3 : "yoncing#tag" 4 : String name="yoncing"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello yoncing uum"); }
Microsoft Windows [Version 10.0.17134.1006] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\HP>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> "syiqin" $1 ==> "syiqin"
jshell> /exit | Goodbye
C:\Users\HP>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> "syiqin" $1 ==> "syiqin" | created scratch variable $1 : String
jshell> "UUM" $2 ==> "UUM" | created scratch variable $2 : String
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM"
jshell> String name = "syiqin nawi" name ==> "syiqin nawi" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> $1 + $2 $5 ==> "syiqinUUM" | created scratch variable $5 : String
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> 7-0 $7 ==> 7 | created scratch variable $7 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM" | String name = "syiqin nawi" | String $name = "SOC" | String $5 = "syiqinUUM" | boolean $6 = false | int $7 = 7 | int age = 21
jshell> double price = 60.10 price ==> 60.1 | created variable price : double
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM" | String name = "syiqin nawi" | String $name = "SOC" | String $5 = "syiqinUUM" | boolean $6 = false | int $7 = 7 | int age = 21 | double price = 60.1
jshell> age + price $10 ==> 81.1 | created scratch variable $10 : double
jshell> age > price $11 ==> false | created scratch variable $11 : boolean
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM" | String name = "syiqin nawi" | String $name = "SOC" | String $5 = "syiqinUUM" | boolean $6 = false | int $7 = 7 | int age = 21 | double price = 60.1 | double $10 = 81.1 | boolean $11 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM" | String name = "syiqin nawi" | String $name = "SOC" | String $5 = "syiqinUUM" | boolean $6 = false | int $7 = 7 | int age = 21 | double price = 60.1 | double $10 = 81.1 | boolean $11 = false
jshell> public void main(String [] args){ ...> System.out.println("Hello World"); ...> } | created method main(String [])
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price 12 : public void main(String [] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "syiqin" | String $2 = "UUM" | String name = "syiqin nawi" | String $name = "SOC" | String $5 = "syiqinUUM" | boolean $6 = false | int $7 = 7 | int age = 21 | double price = 60.1 | double $10 = 81.1 | boolean $11 = false
jshell> public static void main(String [] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String [] args){ | ^-----------^ | modified method main(String []) | update overwrote method main(String [])
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price 13 : public static void main(String [] args){ System.out.println("Hello World"); }
jshell> public static void main(String [] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String [] args){ | ^-----------^ | modified method main(String []) | update overwrote method main(String [])
jshell> public void main(String [] args){ ...> System.out.println("Hello World"); ...> } | modified method main(String []) | update overwrote method main(String [])
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price 15 : public void main(String [] args){ System.out.println("Hello World"); }
jshell> /methods | void main(String [])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /methods | void main(String []) | void main()
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price 15 : public void main(String [] args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 16 | modified method main() | update overwrote method main()
jshell> /list
1 : "syiqin" 2 : "UUM" 3 : String name = "syiqin nawi"; 4 : String $name = "SOC"; 5 : $1 + $2 6 : $1==$2 7 : 7-0 8 : int age = 21; 9 : double price = 60.10; 10 : age + price 11 : age > price 15 : public void main(String [] args){ System.out.println("Hello World"); } 17 : public void main(){ System.out.println("Hello syiqin"); }
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\MSI-PC>java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
C:\Users\MSI-PC>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> kaiting | Error: | cannot find symbol | symbol: variable kaiting | kaiting | ^-----^
jshell> "kaiting" $1 ==> "kaiting"
jshell> /exit | Goodbye
C:\Users\MSI-PC>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> kaiting | Error: | cannot find symbol | symbol: variable kaiting | kaiting | ^-----^
jshell> "kaiting" $1 ==> "kaiting" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "kaiting#tag" $3 ==> "kaiting#tag" | created scratch variable $3 : String
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag"
jshell> String name = "kaiting" name ==> "kaiting" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC"
jshell> $1=$2 $1 ==> "Universiti Utara Malaysia" | assigned to $1 : String
jshell> $1==$2 $7 ==> true | created scratch variable $7 : boolean
jshell> $2==$3 $8 ==> false | created scratch variable $8 : boolean
jshell> $1==$2 $9 ==> true | created scratch variable $9 : boolean
jshell> $1 + $2 $10 ==> "Universiti Utara MalaysiaUniversiti Utara Malaysia" | created scratch variable $10 : String
jshell> /vars | String $1 = "Universiti Utara Malaysia" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia"
jshell> $1 = "kaiting" $1 ==> "kaiting" | assigned to $1 : String
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia"
jshell> $1 + $2 $12 ==> "kaitingUniversiti Utara Malaysia" | created scratch variable $12 : String
jshell> 7+8 $13 ==> 15 | created scratch variable $13 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia" | String $12 = "kaitingUniversiti Utara Malaysia" | int $13 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia" | String $12 = "kaitingUniversiti Utara Malaysia" | int $13 = 15 | int age = 21 | double price = 50.99
jshell> age age ==> 21 | value of age : int
jshell> age + price $17 ==> 71.99000000000001 | created scratch variable $17 : double
jshell> age > price $18 ==> false | created scratch variable $18 : boolean
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia" | String $12 = "kaitingUniversiti Utara Malaysia" | int $13 = 15 | int age = 21 | double price = 50.99 | double $17 = 71.99000000000001 | boolean $18 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "kaiting" 2 : "Universiti Utara Malaysia" 3 : "kaiting#tag" 4 : String name = "kaiting"; 5 : String $name = "SOC"; 6 : $1=$2 7 : $1==$2 8 : $2==$3 9 : $1==$2 10 : $1 + $2 11 : $1 = "kaiting" 12 : $1 + $2 13 : 7+8 14 : int age = 21; 15 : double price = 50.99; 16 : age 17 : age + price 18 : age > price
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia" | String $12 = "kaitingUniversiti Utara Malaysia" | int $13 = 15 | int age = 21 | double price = 50.99 | double $17 = 71.99000000000001 | boolean $18 = false
jshell> public static void main(string[] args){} | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(string[] args){} | ^-----------^ | created method main(string[]), however, it cannot be referenced until class string is declared and this error is corrected: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(string[] args){} | ^-----------^
jshell> public void main(){System.out.println("Hello World");} | created method main()
jshell> /vars | String $1 = "kaiting" | String $2 = "Universiti Utara Malaysia" | String $3 = "kaiting#tag" | String name = "kaiting" | String $name = "SOC" | boolean $7 = true | boolean $8 = false | boolean $9 = true | String $10 = "Universiti Utara MalaysiaUniversiti Utara Malaysia" | String $12 = "kaitingUniversiti Utara Malaysia" | int $13 = 15 | int age = 21 | double price = 50.99 | double $17 = 71.99000000000001 | boolean $18 = false
jshell> /list
1 : "kaiting" 2 : "Universiti Utara Malaysia" 3 : "kaiting#tag" 4 : String name = "kaiting"; 5 : String $name = "SOC"; 6 : $1=$2 7 : $1==$2 8 : $2==$3 9 : $1==$2 10 : $1 + $2 11 : $1 = "kaiting" 12 : $1 + $2 13 : 7+8 14 : int age = 21; 15 : double price = 50.99; 16 : age 17 : age + price 18 : age > price 19 : public static void main(string[] args){} 20 : public void main(){System.out.println("Hello World");}
jshell> /methods | void main(string[]) | which cannot be referenced until class string is declared | void main()
jshell> /list
1 : "kaiting" 2 : "Universiti Utara Malaysia" 3 : "kaiting#tag" 4 : String name = "kaiting"; 5 : String $name = "SOC"; 6 : $1=$2 7 : $1==$2 8 : $2==$3 9 : $1==$2 10 : $1 + $2 11 : $1 = "kaiting" 12 : $1 + $2 13 : 7+8 14 : int age = 21; 15 : double price = 50.99; 16 : age 17 : age + price 18 : age > price 19 : public static void main(string[] args){} 20 : public void main(){System.out.println("Hello World");}
jshell> /edit 20
jshell> /edit 2
jshell> /list
1 : "kaiting" 2 : "Universiti Utara Malaysia" 3 : "kaiting#tag" 4 : String name = "kaiting"; 5 : String $name = "SOC"; 6 : $1=$2 7 : $1==$2 8 : $2==$3 9 : $1==$2 10 : $1 + $2 11 : $1 = "kaiting" 12 : $1 + $2 13 : 7+8 14 : int age = 21; 15 : double price = 50.99; 16 : age 17 : age + price 18 : age > price 19 : public static void main(string[] args){} 20 : public void main(){System.out.println("Hello World");}
jshell> /edit 2 $21 ==> "Universiti Utara Malaysia UUM" | created scratch variable $21 : String
jshell> /list
1 : "kaiting" 2 : "Universiti Utara Malaysia" 3 : "kaiting#tag" 4 : String name = "kaiting"; 5 : String $name = "SOC"; 6 : $1=$2 7 : $1==$2 8 : $2==$3 9 : $1==$2 10 : $1 + $2 11 : $1 = "kaiting" 12 : $1 + $2 13 : 7+8 14 : int age = 21; 15 : double price = 50.99; 16 : age 17 : age + price 18 : age > price 19 : public static void main(string[] args){} 20 : public void main(){System.out.println("Hello World");} 21 : "Universiti Utara Malaysia UUM";
| created variable $name : String
jshell> /vars | String $1 = "kamarudin" | String $2 = "#MrProDin" | String name = "kamarudin yusoff" | String $name = "SOC"
jshell> "Universiti Utara Malaysia" $5 ==> "Universiti Utara Malaysia" | created scratch variable $5 : String
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> /vars | String $1 = "kamarudin" | String $2 = "#MrProDin" | String name = "kamarudin yusoff" | String $name = "SOC" | String $5 = "Universiti Utara Malaysia" | boolean $6 = false
jshell> $1 + $2 $7 ==> "kamarudin#MrProDin" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "kamarudin" | String $2 = "#MrProDin" | String name = "kamarudin yusoff" | String $name = "SOC" | String $5 = "Universiti Utara Malaysia" | boolean $6 = false | String $7 = "kamarudin#MrProDin" | int $8 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "kamarudin" | String $2 = "#MrProDin" | String name = "kamarudin yusoff" | String $name = "SOC" | String $5 = "Universiti Utara Malaysia" | boolean $6 = false | String $7 = "kamarudin#MrProDin" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> age != price $13 ==> true | created scratch variable $13 : boolean
jshell>
jshell>
jshell>
jshell>
jshell>
jshell>
jshell>
jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||
intro | ||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||
keys | ||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||
id | ||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||
context | ||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /re |
set | rerun | a description of ways to re-evaluate previously entered snippets
jshell> /list
1 : "kamarudin" 2 : "#MrProDin" 3 : String name = "kamarudin yusoff"; 4 : String $name = "SOC"; 5 : "Universiti Utara Malaysia" 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /vars | String $1 = "kamarudin" | String $2 = "#MrProDin" | String name = "kamarudin yusoff" | String $name = "SOC" | String $5 = "Universiti Utara Malaysia" | boolean $6 = false | String $7 = "kamarudin#MrProDin" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main( <press tab again to see all possible completions; total possible completions: 53 1> jshell> public static void main(String[]args){} | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){} | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "kamarudin" 2 : "#MrProDin" 3 : String name = "kamarudin yusoff"; 4 : String $name = "SOC"; 5 : "Universiti Utara Malaysia" 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 15 : public void main(){ System.out.println("Hello World"); } 16 : public static void main(String[]args){ System.out.println("Hello World"); }
jshell> /method | void main() | void main(String[])
jshell> /list
1 : "kamarudin" 2 : "#MrProDin" 3 : String name = "kamarudin yusoff"; 4 : String $name = "SOC"; 5 : "Universiti Utara Malaysia" 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 15 : public void main(){ System.out.println("Hello World"); } 16 : public static void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /list
1 : "kamarudin" 2 : "#MrProDin" 3 : String name = "kamarudin yusoff"; 4 : String $name = "SOC"; 5 : "Universiti Utara Malaysia" 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 16 : public static void main(String[]args){ System.out.println("Hello World"); } 17 : public void main(){ System.out.println("Hello World Din"); }
jshell> /edit 2
Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\user>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\user>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "adam" $1 ==> "adam"
jshell> "kelantan" $2 ==> "kelantan"
jshell> /vrs | Invalid command: /vrs | Type /help for help.
jshell> /vars | String $1 = "adam" | String $2 = "kelantan"
jshell> String name name ==> null
jshell> s1=s2 | Error: | cannot find symbol | symbol: variable s1 | s1=s2 | ^^ | Error: | cannot find symbol | symbol: variable s2 | s1=s2 | ^^
jshell> $1=$2 $1 ==> "kelantan"
jshell> $1==$2 $5 ==> true
jshell> "adam nuqman" $6 ==> "adam nuqman"
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | String name = null | boolean $5 = true | String $6 = "adam nuqman"
jshell> $1+$6 $7 ==> "kelantanadam nuqman"
jshell> 0.1+1 $8 ==> 1.1
jshell> int price=50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price=50.99; | ^---^
jshell> 7=8 | Error: | unexpected type | required: variable | found: value | 7=8 | ^
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | String name = null | boolean $5 = true | String $6 = "adam nuqman" | String $7 = "kelantanadam nuqman" | double $8 = 1.1
jshell> int=1.1 | Error: | '.class' expected | int=1.1 | ^ | Error: | unexpected type | required: variable | found: class | int=1.1 | ^-^
jshell> double=1.1 | Error: | '.class' expected | double=1.1 | ^ | Error: | unexpected type | required: variable | found: class | double=1.1 | ^----^
jshell> double price=50.99 price ==> 50.99
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | String name = null | boolean $5 = true | String $6 = "adam nuqman" | String $7 = "kelantanadam nuqman" | double $8 = 1.1 | double price = 50.99
jshell> int age=19 age ==> 19
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | String name = null | boolean $5 = true | String $6 = "adam nuqman" | String $7 = "kelantanadam nuqman" | double $8 = 1.1 | double price = 50.99 | int age = 19
jshell> age+price $11 ==> 69.99000000000001
jshell> String name="adam nuqman" name ==> "adam nuqman"
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | boolean $5 = true | String $6 = "adam nuqman" | String $7 = "kelantanadam nuqman" | double $8 = 1.1 | double price = 50.99 | int age = 19 | double $11 = 69.99000000000001 | String name = "adam nuqman"
jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||
intro | ||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||
keys | ||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||
id | ||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||
context | ||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /re |
set | rerun | a description of ways to re-evaluate previously entered snippets
jshell> /list
1 : "adam" 2 : "kelantan" 4 : $1=$2 5 : $1==$2 6 : "adam nuqman" 7 : $1+$6 8 : 0.1+1 9 : double price=50.99; 10 : int age=19; 11 : age+price 12 : String name="adam nuqman";
jshell> age>price $13 ==> false
jshell> /vars | String $1 = "kelantan" | String $2 = "kelantan" | boolean $5 = true | String $6 = "adam nuqman" | String $7 = "kelantanadam nuqman" | double $8 = 1.1 | double price = 50.99 | int age = 19 | double $11 = 69.99000000000001 | String name = "adam nuqman" | boolean $13 = false
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /metthods | Invalid command: /metthods | Type /help for help.
jshell> /methods | void main()
jshell> /edit8 | Invalid command: /edit8 | Type /help for help.
jshell> /list
1 : "adam" 2 : "kelantan" 4 : $1=$2 5 : $1==$2 6 : "adam nuqman" 7 : $1+$6 8 : 0.1+1 9 : double price=50.99; 10 : int age=19; 11 : age+price 12 : String name="adam nuqman"; 13 : age>price 14 : public void main(){ System.out.println("Hello World"); }
jshell> /edit
jshell>
C:\Users\ADMIN>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro jshell> /exit | Goodbye jshell> "abraham" $1 ==> "abraham" jshell> /vars | String $1 = "abraham"
jshell> /list
1 : "abraham" 2 : "good" 3 : $1==$2 4 : $1+$2 5 : 7+8 6 : int age =21; 7 : double price = 50.99; 8 : age + price 9 : age > price 10 : public void main(string[] args){ System.out.println("HelloWorld"); } 11 : System.out.println("HelloWorld");
jshell> /vars | String $1 = "abraham" | String $2 = "good" | boolean $3 = false | String $4 = "abrahamgood" | int $5 = 15 | int age = 21 | double price = 50.99 | double $8 = 71.99000000000001 | boolean $9 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell>shell> /vars | String $1 = "abraham" | String $2 = "good" | boolean $3 = false | String $4 = "abrahamgood" | int $5 = 15 | int age = 21 | double price = 50.99 | double $8 = 71.99000000000001 | boolean $9 = false | boolean $12 = false | double $13 = 71.99000000000001 | boolean $14 = true
jshell> /methods | void main(string[]) | which cannot be referenced until class string is declared
jshell> /list
1 : "abraham" 2 : "good" 3 : $1==$2 4 : $1+$2 5 : 7+8 6 : int age =21; 7 : double price = 50.99; 8 : age + price 9 : age > price 10 : public void main(string[] args){ System.out.println("HelloWorld"); } 11 : System.out.println("HelloWorld"); 12 : age > price 13 : age + price 14 : age !=price 15 : age = 21
jshell>jshell> /vars | String $1 = "abraham" | String $2 = "good" | boolean $3 = false | String $4 = "abrahamgood" | int $5 = 15 | int age = 21 | double price = 50.99 | double $8 = 71.99000000000001 | boolean $9 = false | boolean $12 = false | double $13 = 71.99000000000001 | boolean $14 = true | boolean $16 = false | boolean $17 = true
jshell>
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\samsulrizal>java -version java version "12.0.2" 2019-07-16 Java(TM) SE Runtime Environment (build 12.0.2+10) Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\samsulrizal>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> suhadaibrahim | Error: | cannot find symbol | symbol: variable suhadaibrahim | suhadaibrahim | ^-----------^
jshell> "suhadaibrahim" $1 ==> "suhadaibrahim"
jshell> /vars | String $1 = "suhadaibrahim"
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia"
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia"
jshell> "suhada#taq" $3 ==> "suhada#taq"
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq"
jshell> String name = suhadaibrahim | Error: | cannot find symbol | symbol: variable suhadaibrahim | String name = suhadaibrahim; | ^-----------^
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq"
jshell> String name = "suhadaibrahim" name ==> "suhadaibrahim"
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim"
jshell> String $ name = "SOC" | Error: | ';' expected | String $ name = "SOC"; | ^
jshell> String $name = "SOC" $name ==> "SOC"
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC"
jshell> $1==$2 $6 ==> false
jshell> $1 + $2 $7 ==> "suhadaibrahimUniversiti Utara Malaysia"
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15
jshell> int age = 21 age ==> 21
jshell>
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> double price = 50.99 price ==> 50.99
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age = price | Error: | incompatible types: possible lossy conversion from double to int | age = price | ^---^
jshell> age + price $11 ==> 71.99000000000001
jshell> age > price $12 ==> false
jshell> age != price $13 ==> true
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "suhadaibrahim" 2 : "Universiti Utara Malaysia" 3 : "suhada#taq" 4 : String name = "suhadaibrahim"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[] args){ ...> System.out.printIn("Hello World"); ...> } | Error: | cannot find symbol | symbol: method printIn(java.lang.String) | System.out.printIn("Hello World"); | ^----------------^ | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "suhadaibrahim" 2 : "Universiti Utara Malaysia" 3 : "suhada#taq" 4 : String name = "suhadaibrahim"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /edit $14 ==> "suhadaibrahim UUM"
jshell> /vars | String $1 = "suhadaibrahim" | String $2 = "Universiti Utara Malaysia" | String $3 = "suhada#taq" | String name = "suhadaibrahim" | String $name = "SOC" | boolean $6 = false | String $7 = "suhadaibrahimUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true | String $14 = "suhadaibrahim UUM"
jshell>
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\Aspire E1>jshell
| Welcome to JShell -- Version 12.0.2
| For an introduction type: /help intro
jshell> julie
| Error:
| cannot find symbol
| symbol: variable julie
| julie
| ^---^
jshell> "julie"
$1 ==> "julie"
jshell> /exit
| Goodbye
C:\Users\Aspire E1>jshell -v
| Welcome to JShell -- Version 12.0.2
| For an introduction type: /help intro
jshell> "julie"
$1 ==> "julie"
| created scratch variable $1 : String
jshell> "julie#tag"
$2 ==> "julie#tag"
| created scratch variable $2 : String
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
jshell> String name = "Juliney Sen"
name ==> "Juliney Sen"
| created variable name : String
jshell> String $name = "SOC"
$name ==> "SOC"
| created variable $name : String
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
jshell> $1==$2
$5 ==> false
| created scratch variable $5 : boolean
jshell> $1 + $2
$6 ==> "juliejulie#tag"
| created scratch variable $6 : String
jshell> 7+8
$7 ==> 15
| created scratch variable $7 : int
jshell> int age = 21
age ==> 21
| created variable age : int
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
| boolean $5 = false
| String $6 = "juliejulie#tag"
| int $7 = 15
| int age = 21
jshell> int price = 50.99
| Error:
| incompatible types: possible lossy conversion from double to int
| int price = 50.99;
| ^---^
jshell> double price = 50.99
price ==> 50.99
| created variable price : double
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
| boolean $5 = false
| String $6 = "juliejulie#tag"
| int $7 = 15
| int age = 21
| double price = 50.99
jshell> age + price
$10 ==> 71.99000000000001
| created scratch variable $10 : double
jshell> age>price
$11 ==> false
| created scratch variable $11 : boolean
jshell> age!= price
$12 ==> true
| created scratch variable $12 : boolean
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
| boolean $5 = false
| String $6 = "juliejulie#tag"
| int $7 = 15
| int age = 21
| double price = 50.99
| double $10 = 71.99000000000001
| boolean $11 = false
| boolean $12 = true
jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [<name or id>|-all|-start]
| list the source you have typed
| /edit <name or id>
| edit a source entry
| /drop <name or id>
| delete a source entry
| /save [-all|-history|-start] <file>
| Save snippet source to a file
| /open <file>
| open a file as source input
| /vars [<name or id>|-all|-start]
| list the declared variables and their values
| /methods [<name or id>|-all|-start]
| list the declared methods and their signatures
| /types [<name or id>|-all|-start]
| list the type declarations
| /imports
| list the imported items
| /exit [<integer-expression-snippet>]
| exit the jshell tool
| /env [-class-path <path>] [-module-path <path>] [-add-modules <modules>] ...
| view or change the evaluation context
| /reset [-class-path <path>] [-module-path <path>] [-add-modules <modules>]...
| reset the jshell tool
| /reload [-restore] [-quiet] [-class-path <path>] [-module-path <path>]...
| reset and replay relevant history -- current or previous (-restore)
| /history [-all]
| history of what you have typed
| /help [<command>|<subject>]
| get information about using the jshell tool
| /set editor|start|feedback|mode|prompt|truncation|format ...
| set configuration information
| /? [<command>|<subject>]
| get information about using the jshell tool
| /!
| rerun last snippet -- see /help rerun
| /<id>
| rerun snippets by ID or ID range -- see /help rerun
| /-<n>
| rerun n-th previous snippet -- see /help rerun
|
| For more information type '/help' followed by the name of a
| command or a subject.
| For example '/help /list' or '/help intro'.
|
| Subjects:
|
| intro
| an introduction to the jshell tool
| keys
| a description of readline-like input editing
| id
| a description of snippet IDs and how use them
| shortcuts
| a description of keystrokes for snippet and command completion,
| information access, and automatic code generation
| context
| a description of the evaluation context options for /env /reload and /re
set
| rerun
| a description of ways to re-evaluate previously entered snippets
jshell> /list
1 : "julie"
2 : "julie#tag"
3 : String name = "Juliney Sen";
4 : String $name = "SOC";
5 : $1==$2
6 : $1 + $2
7 : 7+8
8 : int age = 21;
9 : double price = 50.99;
10 : age + price
11 : age>price
12 : age!= price
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
| boolean $5 = false
| String $6 = "juliejulie#tag"
| int $7 = 15
| int age = 21
| double price = 50.99
| double $10 = 71.99000000000001
| boolean $11 = false
| boolean $12 = true
jshell> public static void main(String[] args){
...> System.out.print("HelloWorld");
...> }
| Warning:
| Modifier 'static' not permitted in top-level declarations, ignored
| public static void main(String[] args){
| ^-----------^
| created method main(String[])
jshell> public void main(){
...> System.out.println("HelloWorld");
...> }
| created method main()
jshell> /list
1 : "julie"
2 : "julie#tag"
3 : String name = "Juliney Sen";
4 : String $name = "SOC";
5 : $1==$2
6 : $1 + $2
7 : 7+8
8 : int age = 21;
9 : double price = 50.99;
10 : age + price
11 : age>price
12 : age!= price
13 : public static void main(String[] args){
System.out.print("HelloWorld");
}
14 : public void main(){
System.out.println("HelloWorld");
}
jshell> /vars
| String $1 = "julie"
| String $2 = "julie#tag"
| String name = "Juliney Sen"
| String $name = "SOC"
| boolean $5 = false
| String $6 = "juliejulie#tag"
| int $7 = 15
| int age = 21
| double price = 50.99
| double $10 = 71.99000000000001
| boolean $11 = false
| boolean $12 = true
jshell> /methods
| void main(String[])
| void main()
jshell> /edit 14
jshell> /list
1 : "julie"
2 : "julie#tag"
3 : String name = "Juliney Sen";
4 : String $name = "SOC";
5 : $1==$2
6 : $1 + $2
7 : 7+8
8 : int age = 21;
9 : double price = 50.99;
10 : age + price
11 : age>price
12 : age!= price
13 : public static void main(String[] args){
System.out.print("HelloWorld");
}
14 : public void main(){
System.out.println("HelloWorld");
}
jshell> /edit 2
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Jie Sheng>java -version java version "12.0.2" 2019-07-16 Java(TM) SE Runtime Environment (build 12.0.2+10) Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\Jie Sheng>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell>
jiesheng | Error: | cannot find symbol | symbol: variable jiesheng | jiesheng | ^------^
jshell> "jiesheng" $1 ==> "jiesheng"
jshell> /exit | Goodbye
C:\Users\Jie Sheng>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> jiesheng | Error: | cannot find symbol | symbol: variable jiesheng | jiesheng | ^------^
jshell> "jiesheng" $1 ==> "jiesheng" | created scratch variable $1 : String
jshell> "universiti Utara Malaysia" $2 ==> "universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "jiesheng#tag" $3 ==> "jiesheng#tag" | created scratch variable $3 : String
jshell> 'jiesheng' jshell> : | unclosed character literal jshell> heng' | ^ jshell> : | unclosed character literal jshell> heng' | ^ jshell> : | reached end of file while parsing | 'jiesheng' | ^
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag"
jshell> String name = "chai jie sheng" name ==> "chai jie sheng" | created variable name : String
jshell> "SOC" $5 ==> "SOC" | created scratch variable $5 : String
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC"
jshell> s1==s2 | Error: | cannot find symbol | symbol: variable s1 | s1==s2 | ^^ | Error: | cannot find symbol | symbol: variable s2 | s1==s2 | ^^
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "jieshenguniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC" | boolean $6 = false | String $7 = "jieshenguniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC" | boolean $6 = false | String $7 = "jieshenguniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age>price $12 ==> false | created scratch variable $12 : boolean
jshell> age!=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC" | boolean $6 = false | String $7 = "jieshenguniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "jiesheng" 2 : "universiti Utara Malaysia" 3 : "jiesheng#tag" 4 : String name = "chai jie sheng"; 5 : "SOC" 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age!=price
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC" | boolean $6 = false | String $7 = "jieshenguniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args{ System.out.println("Hello World");} ...> ...> ...> /exit ...> System.out.println("Hello World"); ...> } | Error: | ',', ')', or '[' expected | public static void main(String[]args{ System.out.println("Hello World");} | ^
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /list
1 : "jiesheng" 2 : "universiti Utara Malaysia" 3 : "jiesheng#tag" 4 : String name = "chai jie sheng"; 5 : "SOC" 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 15 : public void main(){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "jiesheng" | String $2 = "universiti Utara Malaysia" | String $3 = "jiesheng#tag" | String name = "chai jie sheng" | String $5 = "SOC" | boolean $6 = false | String $7 = "jieshenguniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /method | void main(String[]) | void main()
jshell> /list
1 : "jiesheng" 2 : "universiti Utara Malaysia" 3 : "jiesheng#tag" 4 : String name = "chai jie sheng"; 5 : "SOC" 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 15 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /list
1 : "jiesheng" 2 : "universiti Utara Malaysia" 3 : "jiesheng#tag" 4 : String name = "chai jie sheng"; 5 : "SOC" 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 2
jshell> /edit 2 $17 ==> "universiti Utara Malaysia" | created scratch variable $17 : String
jshell> /list
1 : "jiesheng" 2 : "universiti Utara Malaysia" 3 : "jiesheng#tag" 4 : String name = "chai jie sheng"; 5 : "SOC" 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age>price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("Hello World"); } 16 : public void main(){ System.out.println("Hello World"); } 17 : "universiti Utara Malaysia";
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\ngmun>java -version java version "13" 2019-09-17 Java(TM) SE Runtime Environment (build 13+33) Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
C:\Users\ngmun>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "NgMunOnn" $1 ==> "NgMunOnn"
jshell> /exit | Goodbye
C:\Users\ngmun> -v '-v' is not recognized as an internal or external command, operable program or batch file.
C:\Users\ngmun>jshell -v | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "NgMunOnn" $1 ==> "NgMunOnn" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "NgMunOnn#tag" $3 ==> "NgMunOnn#tag" | created scratch variable $3 : String
jshell> 'NgMunOnn' | Error: | unclosed character literal | 'NgMunOnn' | ^ | Error: | unclosed character literal | 'NgMunOnn' | ^ | Error: | reached end of file while parsing | 'NgMunOnn' | ^
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag"
jshell> String name ="NgMunOnn" name ==> "NgMunOnn" | created variable name : String
jshell> String $name ="SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC"
jshell> s1==s2 | Error: | cannot find symbol | symbol: variable s1 | s1==s2 | ^^ | Error: | cannot find symbol | symbol: variable s2 | s1==s2 | ^^
jshell> $1==S2 | Error: | cannot find symbol | symbol: variable S2 | $1==S2 | ^^
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "NgMunOnnUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1-$2 | Error: | bad operand types for binary operator '-' | first type: java.lang.String | second type: java.lang.String | $1-$2 | ^---^
jshell> 19+18 $8 ==> 37 | created scratch variable $8 : int
jshell> int age 21 | Error: | ';' expected | int age 21 | ^
jshell> int age =21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC" | boolean $6 = false | String $7 = "NgMunOnnUniversiti Utara Malaysia" | int $8 = 37 | int age = 21
jshell> int price =50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price =50.99; | ^---^
jshell> double price =50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC" | boolean $6 = false | String $7 = "NgMunOnnUniversiti Utara Malaysia" | int $8 = 37 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> age!=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC" | boolean $6 = false | String $7 = "NgMunOnnUniversiti Utara Malaysia" | int $8 = 37 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "NgMunOnn" 2 : "Universiti Utara Malaysia" 3 : "NgMunOnn#tag" 4 : String name ="NgMunOnn"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 19+18 9 : int age =21; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age!=price
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC" | boolean $6 = false | String $7 = "NgMunOnnUniversiti Utara Malaysia" | int $8 = 37 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("HelloWorld"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("HelloWorld"); ...> } | created method main()
jshell> /list
1 : "NgMunOnn" 2 : "Universiti Utara Malaysia" 3 : "NgMunOnn#tag" 4 : String name ="NgMunOnn"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 19+18 9 : int age =21; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("HelloWorld"); } 15 : public void main(){ System.out.println("HelloWorld"); }
jshell> /vars | String $1 = "NgMunOnn" | String $2 = "Universiti Utara Malaysia" | String $3 = "NgMunOnn#tag" | String name = "NgMunOnn" | String $name = "SOC" | boolean $6 = false | String $7 = "NgMunOnnUniversiti Utara Malaysia" | int $8 = 37 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /method | void main(String[]) | void main()
jshell> /list
1 : "NgMunOnn" 2 : "Universiti Utara Malaysia" 3 : "NgMunOnn#tag" 4 : String name ="NgMunOnn"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 19+18 9 : int age =21; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("HelloWorld"); } 15 : public void main(){ System.out.println("HelloWorld"); }
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /list
1 : "NgMunOnn" 2 : "Universiti Utara Malaysia" 3 : "NgMunOnn#tag" 4 : String name ="NgMunOnn"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 19+18 9 : int age =21; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("HelloWorld"); } 16 : public void main(){ System.out.println("Kampar,Perak"); }
jshell> /edit 2
jshell> /list
1 : "NgMunOnn" 2 : "Universiti Utara Malaysia" 3 : "NgMunOnn#tag" 4 : String name ="NgMunOnn"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 19+18 9 : int age =21; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age!=price 14 : public static void main(String[]args){ System.out.println("HelloWorld"); } 16 : public void main(){ System.out.println("Kampar,Perak"); }
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\User>java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode, sharing)
C:\Users\User>jshell
| Welcome to JShell -- Version 12.0.2
| For an introduction type: /help intro
jshell> "elin"
$1 ==> "elin"
jshell> /exit
| Goodbye
C:\Users\User>jshell -v
| Welcome to JShell -- Version 12.0.2
| For an introduction type: /help intro
jshell> "elin"
$1 ==> "elin"
| created scratch variable $1 : String
jshell> /vars
| String $1 = "elin"
jshell> "elin#tag"
$2 ==> "elin#tag"
| created scratch variable $2 : String
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
jshell> String name = "elin"
name ==> "elin"
| created variable name : String
jshell> String $name = "SOC"
$name ==> "SOC"
| created variable $name : String
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
jshell> $1==$2
$5 ==> false
| created scratch variable $5 : boolean
jshell> 7+8
$6 ==> 15
| created scratch variable $6 : int
jshell> int age = 21
age ==> 21
| created variable age : int
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
| boolean $5 = false
| int $6 = 15
| int age = 21
jshell> int price = 50.99
| Error:
| incompatible types: possible lossy conversion from double to int
| int price = 50.99;
| ^---^
jshell> double price = 50.99
price ==> 50.99
| created variable price : double
jshell> vars
| Error:
| cannot find symbol
| symbol: variable vars
| vars
| ^--^
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
| boolean $5 = false
| int $6 = 15
| int age = 21
| double price = 50.99
jshell> age + price
$9 ==> 71.99000000000001
| created scratch variable $9 : double
jshell> age
age ==> 21
| value of age : int
jshell> age>price
$11 ==> false
| created scratch variable $11 : boolean
jshell> age! = price
| Error:
| ';' expected
| age! = price
| ^
| Error:
| not a statement
| age! = price
| ^---^
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
| boolean $5 = false
| int $6 = 15
| int age = 21
| double price = 50.99
| double $9 = 71.99000000000001
| boolean $11 = false
jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [<name or id>|-all|-start]
| list the source you have typed
| /edit <name or id>
| edit a source entry
| /drop <name or id>
| delete a source entry
| /save [-all|-history|-start] <file>
| Save snippet source to a file
| /open <file>
| open a file as source input
| /vars [<name or id>|-all|-start]
| list the declared variables and their values
| /methods [<name or id>|-all|-start]
| list the declared methods and their signatures
| /types [<name or id>|-all|-start]
| list the type declarations
| /imports
| list the imported items
| /exit [<integer-expression-snippet>]
| exit the jshell tool
| /env [-class-path <path>] [-module-path <path>] [-add-modules <modules>] ...
| view or change the evaluation context
| /reset [-class-path <path>] [-module-path <path>] [-add-modules <modules>]...
| reset the jshell tool
| /reload [-restore] [-quiet] [-class-path <path>] [-module-path <path>]...
| reset and replay relevant history -- current or previous (-restore)
| /history [-all]
| history of what you have typed
| /help [<command>|<subject>]
| get information about using the jshell tool
| /set editor|start|feedback|mode|prompt|truncation|format ...
| set configuration information
| /? [<command>|<subject>]
| get information about using the jshell tool
| /!
| rerun last snippet -- see /help rerun
| /<id>
| rerun snippets by ID or ID range -- see /help rerun
| /-<n>
| rerun n-th previous snippet -- see /help rerun
|
| For more information type '/help' followed by the name of a
| command or a subject.
| For example '/help /list' or '/help intro'.
|
| Subjects:
|
| intro
| an introduction to the jshell tool
| keys
| a description of readline-like input editing
| id
| a description of snippet IDs and how use them
| shortcuts
| a description of keystrokes for snippet and command completion,
| information access, and automatic code generation
| context
| a description of the evaluation context options for /env /reload and /reset
| rerun
| a description of ways to re-evaluate previously entered snippets
jshell> /list
1 : "elin"
2 : "elin#tag"
3 : String name = "elin";
4 : String $name = "SOC";
5 : $1==$2
6 : 7+8
7 : int age = 21;
8 : double price = 50.99;
9 : age + price
10 : age
11 : age>price
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
| boolean $5 = false
| int $6 = 15
| int age = 21
| double price = 50.99
| double $9 = 71.99000000000001
| boolean $11 = false
jshell> public static void main (String[] args){
...> system.out.println("helloworld");
...> }
| Error:
| package system does not exist
| system.out.println("helloworld");
| ^--------^
| Warning:
| Modifier 'static' not permitted in top-level declarations, ignored
| public static void main (String[] args){
| ^-----------^
jshell> public void main(){
...> System.out.println("helloworld");
...> }
| created method main()
jshell> /list
1 : "elin"
2 : "elin#tag"
3 : String name = "elin";
4 : String $name = "SOC";
5 : $1==$2
6 : 7+8
7 : int age = 21;
8 : double price = 50.99;
9 : age + price
10 : age
11 : age>price
12 : public void main(){
System.out.println("helloworld");
}
jshell> /vars
| String $1 = "elin"
| String $2 = "elin#tag"
| String name = "elin"
| String $name = "SOC"
| boolean $5 = false
| int $6 = 15
| int age = 21
| double price = 50.99
| double $9 = 71.99000000000001
| boolean $11 = false
jshell> /methods
| void main()
jshell> edit 14
| Error:
| ';' expected
| edit 14
| ^
| Error:
| cannot find symbol
| symbol: variable edit
| edit 14
| ^--^
jshell> /list
1 : "elin"
2 : "elin#tag"
3 : String name = "elin";
4 : String $name = "SOC";
5 : $1==$2
6 : 7+8
7 : int age = 21;
8 : double price = 50.99;
9 : age + price
10 : age
11 : age>price
12 : public void main(){
System.out.println("helloworld");
}
jshell> /edit 2
jshell>
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\User>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> Goh Fang Yao | Error: | ';' expected | Goh Fang Yao; | ^
jshell> "Goh Fang Yao" $1 ==> "Goh Fang Yao"
jshell> /exit | Goodbye
C:\Users\User>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> Goh Fang Yao" | Error: | ';' expected | Goh Fang Yao" | ^
jshell> "Goh Fang Yao" $1 ==> "Goh Fang Yao" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "GohFangYao#tag" $3 ==> "GohFangYao#tag" | created scratch variable $3 : String
jshell> 'Goh Fang Yao' | Error: | unclosed character literal | 'Goh Fang Yao' | ^ | Error: | unclosed character literal | 'Goh Fang Yao' | ^
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag"
jshell> String name="Goh Fang Yao" name ==> "Goh Fang Yao" | created variable name : String
jshell> String $name= "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag" | String name = "Goh Fang Yao" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "Goh Fang YaoUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age=21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag" | String name = "Goh Fang Yao" | String $name = "SOC" | boolean $6 = false | String $7 = "Goh Fang YaoUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price=50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price=50.99; | ^---^
jshell> double price=50.99 price ==> 50.99 | created variable price : double
jshell> age+price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age>price $12 ==> false | created scratch variable $12 : boolean
jshell> age!=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag" | String name = "Goh Fang Yao" | String $name = "SOC" | boolean $6 = false | String $7 = "Goh Fang YaoUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "Goh Fang Yao" 2 : "Universiti Utara Malaysia" 3 : "GohFangYao#tag" 4 : String name="Goh Fang Yao"; 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag" | String name = "Goh Fang Yao" | String $name = "SOC" | boolean $6 = false | String $7 = "Goh Fang YaoUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[])
...> System.out.println("Hello World");
| Error:
|
jshell> public void main(String[]args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "Goh Fang Yao" 2 : "Universiti Utara Malaysia" 3 : "GohFangYao#tag" 4 : String name="Goh Fang Yao"; 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "Goh Fang Yao" | String $2 = "Universiti Utara Malaysia" | String $3 = "GohFangYao#tag" | String name = "Goh Fang Yao" | String $name = "SOC" | boolean $6 = false | String $7 = "Goh Fang YaoUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /methods | void main(String[])
jshell> /list
1 : "Goh Fang Yao" 2 : "Universiti Utara Malaysia" 3 : "GohFangYao#tag" 4 : String name="Goh Fang Yao"; 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /list
1 : "Goh Fang Yao" 2 : "Universiti Utara Malaysia" 3 : "GohFangYao#tag" 4 : String name="Goh Fang Yao"; 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 15 | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "Goh Fang Yao" 2 : "Universiti Utara Malaysia" 3 : "GohFangYao#tag" 4 : String name="Goh Fang Yao"; 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 16 : public void main(String[]args){ System.out.println("Hello Goh Fang Yao UUM"); }
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Admin>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> xiuniang | Error: | cannot find symbol | symbol: variable xiuniang | xiuniang | ^------^
jshell> "xiuniang" $1 ==> "xiuniang"
jshell> /exit | Goodbye
C:\Users\Admin>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> xiuniang | Error: | cannot find symbol | symbol: variable xiuniang | xiuniang | ^------^
jshell> "xiuniang" $1 ==> "xiuniang" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "xiuniang#tag" $3 ==> "xiuniang#tag" | created scratch variable $3 : String
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag"
jshell> String name = "lee xiu niang" name ==> "lee xiu niang" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag" | String name = "lee xiu niang" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1 + $2 $7 ==> "xiuniangUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag" | String name = "lee xiu niang" | String $name = "SOC" | boolean $6 = false | String $7 = "xiuniangUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> age != price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag" | String name = "lee xiu niang" | String $name = "SOC" | boolean $6 = false | String $7 = "xiuniangUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "xiuniang" 2 : "Universiti Utara Malaysia" 3 : "xiuniang#tag" 4 : String name = "lee xiu niang"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag" | String name = "lee xiu niang" | String $name = "SOC" | boolean $6 = false | String $7 = "xiuniangUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[] args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "xiuniang" 2 : "Universiti Utara Malaysia" 3 : "xiuniang#tag" 4 : String name = "lee xiu niang"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "xiuniang" | String $2 = "Universiti Utara Malaysia" | String $3 = "xiuniang#tag" | String name = "lee xiu niang" | String $name = "SOC" | boolean $6 = false | String $7 = "xiuniangUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /methods | void main(String[])
jshell> /edit 15 | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "xiuniang" 2 : "Universiti Utara Malaysia" 3 : "xiuniang#tag" 4 : String name = "lee xiu niang"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1 + $2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age != price 16 : public void main(String[] args){ System.out.println("Hello UUM"); }
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\HP>jshell | Welcome to JShell -- Version 13-ea | For an introduction type: /help intro
jshell> shenmeng | Error: | cannot find symbol | symbol: variable shenmeng | shenmeng | ^------^
jshell> "shenmeng" $1 ==> "shenmeng"
jshell> /exit | Goodbye
C:\Users\HP>jshell -v | Welcome to JShell -- Version 13-ea | For an introduction type: /help intro
jshell> ngshenmeng | Error: | cannot find symbol | symbol: variable ngshenmeng | ngshenmeng | ^--------^
jshell> "ngshenmeng" $1 ==> "ngshenmeng" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "ngshenmeng#tag" $3 ==> "ngshenmeng#tag" | created scratch variable $3 : String
jshell> 'ngshenmeng' | Error: | unclosed character literal | 'ngshenmeng' | ^ | Error: | unclosed character literal | 'ngshenmeng' | ^ | Error: | reached end of file while parsing | 'ngshenmeng' | ^
jshell> /vars | String $1 = "ngshenmeng" | String $2 = "Universiti Utara Malaysia" | String $3 = "ngshenmeng#tag"
jshell> String $name= "Ng Shen Meng" $name ==> "Ng Shen Meng" | created variable $name : String
jshell> String $name= "SOC" $name ==> "SOC" | modified variable $name : String | update overwrote variable $name : String
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "ngshenmengUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age= 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "ngshenmeng" | String $2 = "Universiti Utara Malaysia" | String $3 = "ngshenmeng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "ngshenmengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price= 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price= 50.99; | ^---^
jshell> double price= 50.99 price ==> 50.99 | created variable price : double
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age!=price $12 ==> true | created scratch variable $12 : boolean
jshell> age>price $13 ==> false | created scratch variable $13 : boolean
jshell> /vars | String $1 = "ngshenmeng" | String $2 = "Universiti Utara Malaysia" | String $3 = "ngshenmeng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "ngshenmengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "ngshenmeng" 2 : "Universiti Utara Malaysia" 3 : "ngshenmeng#tag" 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age= 21; 10 : double price= 50.99; 11 : age + price 12 : age!=price 13 : age>price
jshell> /vars | String $1 = "ngshenmeng" | String $2 = "Universiti Utara Malaysia" | String $3 = "ngshenmeng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "ngshenmengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[] args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "ngshenmeng" 2 : "Universiti Utara Malaysia" 3 : "ngshenmeng#tag" 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age= 21; 10 : double price= 50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "ngshenmeng" | String $2 = "Universiti Utara Malaysia" | String $3 = "ngshenmeng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "ngshenmengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> /methods | void main(String[])
jshell> /list
1 : "ngshenmeng" 2 : "Universiti Utara Malaysia" 3 : "ngshenmeng#tag" 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age= 21; 10 : double price= 50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /list
1 : "ngshenmeng" 2 : "Universiti Utara Malaysia" 3 : "ngshenmeng#tag" 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age= 21; 10 : double price= 50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[] args){ System.out.println("Hello World"); }
jshell> /edit 2
jshell> /edit 15 | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "ngshenmeng" 2 : "Universiti Utara Malaysia" 3 : "ngshenmeng#tag" 5 : String $name= "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age= 21; 10 : double price= 50.99; 11 : age + price 12 : age!=price 13 : age>price 16 : public void main(String[] args){ System.out.println("Hello Ng Shen Meng UUM"); }
Microsoft Windows [Version 10.0.18362.356] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\User>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> guosheng | Error: | cannot find symbol | symbol: variable guosheng | guosheng | ^------^
jshell> "guosheng" $1 ==> "guosheng"
jshell> /exit | Goodbye
C:\Users\User>jshell -v | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> guosheng | Error: | cannot find symbol | symbol: variable guosheng | guosheng | ^------^
jshell> "guosheng" $1 ==> "guosheng" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "guosheng#tag" $3 ==> "guosheng#tag" | created scratch variable $3 : String
jshell> 'guosheng' | Error: | unclosed character literal | 'guosheng' | ^ | Error: | unclosed character literal | 'guosheng' | ^ | Error: | reached end of file while parsing | 'guosheng' | ^
jshell> /vars | String $1 = "guosheng" | String $2 = "Universiti Utara Malaysia" | String $3 = "guosheng#tag"
jshell> String $name= "Guo Sheng" $name ==> "Guo Sheng" | created variable $name : String
jshell> String $name="SOC" $name ==> "SOC" | modified variable $name : String | update overwrote variable $name : String
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "guoshengUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> <press tab again to see all possible completions; total possible completions: 546> jshell> int age=21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "guosheng" | String $2 = "Universiti Utara Malaysia" | String $3 = "guosheng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "guoshengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price=50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price=50.99; | ^---^
jshell> double price=50.99 price ==> 50.99 | created variable price : double
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age!=price $12 ==> true | created scratch variable $12 : boolean
jshell> age>price $13 ==> false | created scratch variable $13 : boolean
jshell> /vars | String $1 = "guosheng" | String $2 = "Universiti Utara Malaysia" | String $3 = "guosheng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "guoshengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "guosheng" 2 : "Universiti Utara Malaysia" 3 : "guosheng#tag" 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age + price 12 : age!=price 13 : age>price
jshell> /vars | String $1 = "guosheng" | String $2 = "Universiti Utara Malaysia" | String $3 = "guosheng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "guoshengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[]){
...> System.out.println("Hello Word");
...> }
| Error:
|
jshell> public void main(String[]args){ ...> System.out.println("Hello Word"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "guosheng" 2 : "Universiti Utara Malaysia" 3 : "guosheng#tag" 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[]args){ System.out.println("Hello Word"); }
jshell> /vars | String $1 = "guosheng" | String $2 = "Universiti Utara Malaysia" | String $3 = "guosheng#tag" | String $name = "SOC" | boolean $6 = false | String $7 = "guoshengUniversiti Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = true | boolean $13 = false
jshell> /methods | void main(String[])
jshell> /list
1 : "guosheng" 2 : "Universiti Utara Malaysia" 3 : "guosheng#tag" 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[]args){ System.out.println("Hello Word"); }
jshell> /edit 15
jshell> /list
1 : "guosheng" 2 : "Universiti Utara Malaysia" 3 : "guosheng#tag" 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age + price 12 : age!=price 13 : age>price 15 : public void main(String[]args){ System.out.println("Hello Word"); }
jshell> /edit 2
jshell> /edit 15 | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "guosheng" 2 : "Universiti Utara Malaysia" 3 : "guosheng#tag" 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age + price 12 : age!=price 13 : age>price 16 : public void main(String[]args){ System.out.println("Hello Guo Sheng UUM"); }
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\User>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> peckyong | Error: | cannot find symbol | symbol: variable peckyong | peckyong | ^------^
jshell> "peckyong" $1 ==> "peckyong"
jshell> /exit | Goodbye
C:\Users\User>jshell -v | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "peckyong" $1 ==> "peckyong" | created scratch variable $1 : String
jshell> "University Utara Malaysia" $2 ==> "University Utara Malaysia" | created scratch variable $2 : String
jshell> "peckyong#tag" $3 ==> "peckyong#tag" | created scratch variable $3 : String
jshell> 'peckyong' | Error: | unclosed character literal | 'peckyong' | ^ | Error: | unclosed character literal | 'peckyong' | ^ | Error: | reached end of file while parsing | 'peckyong' | ^
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag"
jshell> String name = "Tey Peck Yong" name ==> "Tey Peck Yong" | created variable name : String
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "peckyongUniversity Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC" | boolean $6 = false | String $7 = "peckyongUniversity Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price = 50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC" | boolean $6 = false | String $7 = "peckyongUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99
jshell> age + price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> age! = price | Error: | ';' expected | age! = price | ^ | Error: | not a statement | age! = price | ^---^
jshell> age!= price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC" | boolean $6 = false | String $7 = "peckyongUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "peckyong" 2 : "University Utara Malaysia" 3 : "peckyong#tag" 4 : String name = "Tey Peck Yong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age!= price
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC" | boolean $6 = false | String $7 = "peckyongUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World");} | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World");} | created method main()
jshell> /list
1 : "peckyong" 2 : "University Utara Malaysia" 3 : "peckyong#tag" 4 : String name = "Tey Peck Yong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age!= price 14 : public static void main(String[]args){ System.out.println("Hello World");} 15 : public void main(){ System.out.println("Hello World");}
jshell> /vars | String $1 = "peckyong" | String $2 = "University Utara Malaysia" | String $3 = "peckyong#tag" | String name = "Tey Peck Yong" | String $name = "SOC" | boolean $6 = false | String $7 = "peckyongUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /method | void main(String[]) | void main()
jshell> /edit 15 | modified method main() | update overwrote method main()
jshell> /list
1 : "peckyong" 2 : "University Utara Malaysia" 3 : "peckyong#tag" 4 : String name = "Tey Peck Yong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age!= price 14 : public static void main(String[]args){ System.out.println("Hello World");} 16 : public void main(){ System.out.println("Hello peckyong");}
jshell> /edit 2
jshell> /list
1 : "peckyong" 2 : "University Utara Malaysia" 3 : "peckyong#tag" 4 : String name = "Tey Peck Yong"; 5 : String $name = "SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 21; 10 : double price = 50.99; 11 : age + price 12 : age > price 13 : age!= price 14 : public static void main(String[]args){ System.out.println("Hello World");} 16 : public void main(){ System.out.println("Hello peckyong");}
jshell>
Microsoft Windows [Version 10.0.17763.737] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\HP>jshell | Welcome to JShell -- Version 13 | For an introduction type: /help intro
jshell> "nadiah" $1 ==> "nadiah"
jshell> "kuala terengganu darul iman" $2 ==> "kuala terengganu darul iman"
jshell> "nadiah#tag" $3 ==> "nadiah#tag"
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag"
jshell> String name ="nurul nadiah yusuf" name ==> "nurul nadiah yusuf"
jshell> String name ="soc" name ==> "soc"
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag" | String name = "soc"
jshell> S1+$2 | Error: | cannot find symbol | symbol: variable S1 | S1+$2 | ^^
jshell> $1+$2 $6 ==> "nadiahkuala terengganu darul iman"
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag" | String name = "soc" | String $6 = "nadiahkuala terengganu darul iman"
jshell> 7+8 $7 ==> 15
jshell> int age = 21 age ==> 21
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag" | String name = "soc" | String $6 = "nadiahkuala terengganu darul iman" | int $7 = 15 | int age = 21
jshell> double price =50.99 price ==> 50.99
jshell> age + price $10 ==> 71.99000000000001
jshell> age > price $11 ==> false
jshell> age! + price | Error: | ';' expected | age! + price | ^ | Error: | not a statement | age! + price | ^---^
jshell> age < price $12 ==> true
jshell> /edit
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "nadiah" 2 : "kuala terengganu darul iman" 3 : "nadiah#tag" 5 : String name ="soc"; 6 : $1+$2 7 : 7+8 8 : int age = 21; 9 : double price =50.99; 10 : age + price 11 : age > price 12 : age < price
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag" | String name = "soc" | String $6 = "nadiahkuala terengganu darul iman" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> public static void main(String[] args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[] args){ | ^-----------^ | created method main(String[])
jshell> /list
1 : "nadiah" 2 : "kuala terengganu darul iman" 3 : "nadiah#tag" 5 : String name ="soc"; 6 : $1+$2 7 : 7+8 8 : int age = 21; 9 : double price =50.99; 10 : age + price 11 : age > price 12 : age < price 13 : public static void main(String[] args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "nadiah" | String $2 = "kuala terengganu darul iman" | String $3 = "nadiah#tag" | String name = "soc" | String $6 = "nadiahkuala terengganu darul iman" | int $7 = 15 | int age = 21 | double price = 50.99 | double $10 = 71.99000000000001 | boolean $11 = false | boolean $12 = true
jshell> /list
1 : "nadiah" 2 : "kuala terengganu darul iman" 3 : "nadiah#tag" 5 : String name ="soc"; 6 : $1+$2 7 : 7+8 8 : int age = 21; 9 : double price =50.99; 10 : age + price 11 : age > price 12 : age < price 13 : public static void main(String[] args){ System.out.println("Hello World"); }
jshell>
Microsoft Windows [Version 10.0.16299.611] (c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\User>java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
C:\Users\User>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> Wong Carmen | created variable Carmen, however, it cannot be referenced until class Wong is declared
jshell> "Wong Carmen" $2 ==> "Wong Carmen"
jshell> /exit | Goodbye
C:\Users\User>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> Wong Carmen" | Error: | unclosed string literal | Wong Carmen" | ^
jshell> "Wong Carmen" $1 ==> "Wong Carmen" | created scratch variable $1 : String
jshell> "University Utara Malaysia" $2 ==> "University Utara Malaysia" | created scratch variable $2 : String
jshell> "Wong Carmen#tag" $3 ==> "Wong Carmen#tag" | created scratch variable $3 : String
jshell> 'Wong Carmen' | Error: | unclosed character literal | 'Wong Carmen' | ^ | Error: | unclosed character literal | 'Wong Carmen' | ^
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag"
jshell> String name="Wong Carmen" name ==> "Wong Carmen" | created variable name : String
jshell> String $name="SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag" | String name = "Wong Carmen" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "Wong CarmenUniversity Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7=8 | Error: | unexpected type | required: variable | found: value | 7=8 | ^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age=21 age ==> 21 | created variable age : int
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag" | String name = "Wong Carmen" | String $name = "SOC" | boolean $6 = false | String $7 = "Wong CarmenUniversity Utara Malaysia" | int $8 = 15 | int age = 21
jshell> int price=50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price=50.99; | ^---^
jshell> double price=50.99 price ==> 50.99 | created variable price : double
jshell> age+price $11 ==> 71.99000000000001 | created scratch variable $11 : double
jshell> age>price $12 ==> false | created scratch variable $12 : boolean
jshell> age!=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag" | String name = "Wong Carmen" | String $name = "SOC" | boolean $6 = false | String $7 = "Wong CarmenUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "Wong Carmen" 2 : "University Utara Malaysia" 3 : "Wong Carmen#tag" 4 : String name="Wong Carmen"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag" | String name = "Wong Carmen" | String $name = "SOC" | boolean $6 = false | String $7 = "Wong CarmenUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[])
...> System.out.println("Hello World");
| Error:
|
jshell> public void main(String[]args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "Wong Carmen" 2 : "University Utara Malaysia" 3 : "Wong Carmen#tag" 4 : String name="Wong Carmen"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "Wong Carmen" | String $2 = "University Utara Malaysia" | String $3 = "Wong Carmen#tag" | String name = "Wong Carmen" | String $name = "SOC" | boolean $6 = false | String $7 = "Wong CarmenUniversity Utara Malaysia" | int $8 = 15 | int age = 21 | double price = 50.99 | double $11 = 71.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /methods | void main(String[])
jshell> /list
1 : "Wong Carmen" 2 : "University Utara Malaysia" 3 : "Wong Carmen#tag" 4 : String name="Wong Carmen"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /list
1 : "Wong Carmen" 2 : "University Utara Malaysia" 3 : "Wong Carmen#tag" 4 : String name="Wong Carmen"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 15
jshell> /list
1 : "Wong Carmen" 2 : "University Utara Malaysia" 3 : "Wong Carmen#tag" 4 : String name="Wong Carmen"; 5 : String $name="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age=21; 10 : double price=50.99; 11 : age+price 12 : age>price 13 : age!=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
Microsoft Windows [Version 10.0.17134.1006] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\USER>java -version java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
C:\Users\USER>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> afiqah | Error: | cannot find symbol | symbol: variable afiqah | afiqah | ^----^
jshell>
jshell> "afiqah" $1 ==> "afiqah"
jshell> /exit | Goodbye
C:\Users\USER>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> "afiqah" $1 ==> "afiqah" | created scratch variable $1 : String
jshell> /vars | String $1 = "afiqah"
jshell> "afiqah azhan" $2 ==> "afiqah azhan" | created scratch variable $2 : String
jshell> String $name : "SOC" | Error: | ';' expected | String $name : "SOC" | ^
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan"
jshell> $name = "SOC" | Error: | cannot find symbol | symbol: variable $name | $name = "SOC" | ^---^
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan"
jshell> String $name = "SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC"
jshell> $1==$2 $4 ==> false | created scratch variable $4 : boolean
jshell> $1 + $2 $5 ==> "afiqahafiqah azhan" | created scratch variable $5 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $6 ==> 15 | created scratch variable $6 : int
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC" | boolean $4 = false | String $5 = "afiqahafiqah azhan" | int $6 = 15
jshell> int age = 20 age ==> 20 | created variable age : int
jshell> int price = 50.90 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.90; | ^---^
jshell> double price = 50.90 price ==> 50.9 | created variable price : double
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC" | boolean $4 = false | String $5 = "afiqahafiqah azhan" | int $6 = 15 | int age = 20 | double price = 50.9
jshell> age + price $9 ==> 70.9 | created scratch variable $9 : double
jshell> age > price $10 ==> false | created scratch variable $10 : boolean
jshell> age !=price $11 ==> true | created scratch variable $11 : boolean
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC" | boolean $4 = false | String $5 = "afiqahafiqah azhan" | int $6 = 15 | int age = 20 | double price = 50.9 | double $9 = 70.9 | boolean $10 = false | boolean $11 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC" | boolean $4 = false | String $5 = "afiqahafiqah azhan" | int $6 = 15 | int age = 20 | double price = 50.9 | double $9 = 70.9 | boolean $10 = false | boolean $11 = true
jshell> public static void main (String[] args ){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main (String[] args ){ | ^-----------^ | created method main(String[])
jshell> public void main(){ ...> System.out.println("Hello World"); ...> } | created method main()
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price 12 : public static void main (String[] args ){ System.out.println("Hello World"); } 13 : public void main(){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "afiqah" | String $2 = "afiqah azhan" | String $name = "SOC" | boolean $4 = false | String $5 = "afiqahafiqah azhan" | int $6 = 15 | int age = 20 | double price = 50.9 | double $9 = 70.9 | boolean $10 = false | boolean $11 = true
jshell> /methods | void main(String[]) | void main()
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price 12 : public static void main (String[] args ){ System.out.println("Hello World"); } 13 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 2 | Error: | ';' expected | jannatul"afiqah azhan"; | ^ | Error: | cannot find symbol | symbol: variable jannatul | jannatul"afiqah azhan"; | ^------^
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price 12 : public static void main (String[] args ){ System.out.println("Hello World"); } 13 : public void main(){ System.out.println("Hello World"); }
jshell> /edit 13 | modified method main() | update overwrote method main()
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price 12 : public static void main (String[] args ){ System.out.println("Hello World"); } 14 : public void main(){ System.out.println("Hello uum"); }
jshell> /edit2 | Invalid command: /edit2 | Type /help for help.
jshell> /edit 2 $15 ==> "jannatul afiqah azhan" | created scratch variable $15 : String
jshell> /list
1 : "afiqah" 2 : "afiqah azhan" 3 : String $name = "SOC"; 4 : $1==$2 5 : $1 + $2 6 : 7+8 7 : int age = 20; 8 : double price = 50.90; 9 : age + price 10 : age > price 11 : age !=price 12 : public static void main (String[] args ){ System.out.println("Hello World"); } 14 : public void main(){ System.out.println("Hello uum"); } 15 : "jannatul afiqah azhan";
jshell>
Microsoft Windows [Version 10.0.17134.1006] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\acer>java -version java version "12.0.2" 2019-07-16 Java(TM) SE Runtime Environment (build 12.0.2+10) Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
C:\Users\acer>jshell | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> fatin | Error: | cannot find symbol | symbol: variable fatin | fatin | ^---^
jshell> /exit | Goodbye
C:\Users\acer>jshell -v | Welcome to JShell -- Version 12.0.2 | For an introduction type: /help intro
jshell> fatin | Error: | cannot find symbol | symbol: variable fatin | fatin | ^---^
jshell> "fatin" $1 ==> "fatin" | created scratch variable $1 : String
jshell> "Universiti Utara Malaysia" $2 ==> "Universiti Utara Malaysia" | created scratch variable $2 : String
jshell> "fatin#tag" $3 ==> "fatin#tag" | created scratch variable $3 : String
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag"
jshell> String name ="fatin" name ==> "fatin" | created variable name : String
jshell> String $name ="SOC" $name ==> "SOC" | created variable $name : String
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC"
jshell> $1==$2 $6 ==> false | created scratch variable $6 : boolean
jshell> $1+$2 $7 ==> "fatinUniversiti Utara Malaysia" | created scratch variable $7 : String
jshell> $1<$2 | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | $1<$2 | ^---^
jshell> 7+8 $8 ==> 15 | created scratch variable $8 : int
jshell> int age = 20 age ==> 20 | created variable age : int
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20
jshell> int price = 50.99 | Error: | incompatible types: possible lossy conversion from double to int | int price = 50.99; | ^---^
jshell> double price =50.99 price ==> 50.99 | created variable price : double
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20 | double price = 50.99
jshell> age + price $11 ==> 70.99000000000001 | created scratch variable $11 : double
jshell> age > price $12 ==> false | created scratch variable $12 : boolean
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20 | double price = 50.99 | double $11 = 70.99000000000001 | boolean $12 = false
jshell> age !=price $13 ==> true | created scratch variable $13 : boolean
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20 | double price = 50.99 | double $11 = 70.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /help | Type a Java language expression, statement, or declaration. | Or type one of the following commands: | /list [ |
-all | -start] | list the source you have typed | /edit |
edit a source entry | /drop |
delete a source entry | /save [-all | -history | -start] |
Save snippet source to a file | /open |
open a file as source input | /vars [ |
-all | -start] | list the declared variables and their values | /methods [ |
-all | -start] | list the declared methods and their signatures | /types [ |
-all | -start] | list the type declarations | /imports | list the imported items | /exit [ |
exit the jshell tool | /env [-class-path |
view or change the evaluation context | /reset [-class-path |
reset the jshell tool | /reload [-restore] [-quiet] [-class-path |
reset and replay relevant history -- current or previous (-restore) | /history [-all] | history of what you have typed | /help [ |
get information about using the jshell tool | /set editor | start | feedback | mode | prompt | truncation | format ... | set configuration information | /? [ |
get information about using the jshell tool | /! | rerun last snippet -- see /help rerun | / |
rerun snippets by ID or ID range -- see /help rerun | /- |
rerun n-th previous snippet -- see /help rerun | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
For more information type '/help' followed by the name of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command or a subject. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For example '/help /list' or '/help intro'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
an introduction to the jshell tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of readline-like input editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of snippet IDs and how use them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shortcuts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of keystrokes for snippet and command completion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
information access, and automatic code generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of the evaluation context options for /env /reload and /reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rerun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a description of ways to re-evaluate previously entered snippets |
jshell> /list
1 : "fatin" 2 : "Universiti Utara Malaysia" 3 : "fatin#tag" 4 : String name ="fatin"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 20; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age !=price
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20 | double price = 50.99 | double $11 = 70.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> public static void main(String[]args){ ...> System.out.println("Hello World"); ...> } | Warning: | Modifier 'static' not permitted in top-level declarations, ignored | public static void main(String[]args){ | ^-----------^ | created method main(String[])
jshell> public void main(String[]args){ ...> System.out.println("Hello World"); ...> } | modified method main(String[]) | update overwrote method main(String[])
jshell> /list
1 : "fatin" 2 : "Universiti Utara Malaysia" 3 : "fatin#tag" 4 : String name ="fatin"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 20; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age !=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /vars | String $1 = "fatin" | String $2 = "Universiti Utara Malaysia" | String $3 = "fatin#tag" | String name = "fatin" | String $name = "SOC" | boolean $6 = false | String $7 = "fatinUniversiti Utara Malaysia" | int $8 = 15 | int age = 20 | double price = 50.99 | double $11 = 70.99000000000001 | boolean $12 = false | boolean $13 = true
jshell> /methods | void main(String[])
jshell> /list
1 : "fatin" 2 : "Universiti Utara Malaysia" 3 : "fatin#tag" 4 : String name ="fatin"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 20; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age !=price 15 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> edit 15 | Error: | ';' expected | edit 15 | ^ | Error: | cannot find symbol | symbol: variable edit | edit 15 | ^--^
jshell> /edit 15 | modified method main(String[]) | update overwrote method main(String[])
jshell> / | Command: '/' is ambiguous: /list, /edit, /drop, /save, /open, /vars, /methods, /types, /imports, /exit, /env, /reset, /reload, /history, /debug, /help, /set, /?, /! | Type /help for help.
jshell> /edit 15
jshell> /list
1 : "fatin" 2 : "Universiti Utara Malaysia" 3 : "fatin#tag" 4 : String name ="fatin"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 20; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age !=price 16 : public void main(String[]args){ System.out.println("Hello World"); }
jshell> /edit 2
jshell> /list
1 : "fatin" 2 : "Universiti Utara Malaysia" 3 : "fatin#tag" 4 : String name ="fatin"; 5 : String $name ="SOC"; 6 : $1==$2 7 : $1+$2 8 : 7+8 9 : int age = 20; 10 : double price =50.99; 11 : age + price 12 : age > price 13 : age !=price 16 : public void main(String[]args){ System.out.println("Hello World"); }
jshell>
Instruction:
Paste your Jshell exercise here