(base) MAC:Thu Oct 15:11:08:Desktop> vi Foo.java (base) MAC:Thu Oct 15:11:08:Desktop> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> /open Foo.java jshell> f | Error: | cannot find symbol | symbol: variable f | f | ^ jshell> Foo f = new Foo(); f ==> Foo@31cefde0 jshell> f.hashCode() $3 ==> 835648992 jshell> Integer.toString(f.hashCode(), 16) $4 ==> "31cefde0" jshell> "a".hashCode() $5 ==> 97 jshell> "abc".hashCode() $6 ==> 96354 jshell> String s = "some"; s ==> "some" jshell> String t = "thing"; t ==> "thing" jshell> s + t $9 ==> "something" jshell> s*50 | Error: | bad operand types for binary operator '*' | first type: java.lang.String | second type: int | s*50 | ^--^ jshell> s.repeat(50) $10 ==> "somesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesomesome" jshell> s[0] | Error: | array required, but java.lang.String found | s[0] | ^--^ jshell> s.charAt(0) $11 ==> 's' jshell> s.concat(t) $12 ==> "something" jshell> s.charAt(45) | Exception java.lang.StringIndexOutOfBoundsException: String index out of range: 45 | at StringLatin1.charAt (StringLatin1.java:48) | at String.charAt (String.java:711) | at (#13:1) jshell> s < t | Error: | bad operand types for binary operator '<' | first type: java.lang.String | second type: java.lang.String | s < t | ^---^ jshell> s.compareTo(t) $14 ==> -1 jshell> s.compareTo(t) < 0 $15 ==> true jshell> s.comparetTo(t) > 0 | Error: | cannot find symbol | symbol: method comparetTo(java.lang.String) | s.comparetTo(t) > 0 | ^----------^ jshell> s.compareTo(t) > 0 $16 ==> false jshell> "a".compareTo("z") $17 ==> -25 jshell> (int)'a' $18 ==> 97 jshell> (int)'z' $19 ==> 122 jshell> "abby".compareTo("acid") $20 ==> -1 jshell> "abby".comparetTo("acid") < 0 // "abby" < "acid" (python) | Error: | cannot find symbol | symbol: method comparetTo(java.lang.String) | "abby".comparetTo("acid") < 0 // "abby" < "acid" (python) | ^---------------^ jshell> "abby".compareTo("acid") < 0 // "abby" < "acid" (python) $21 ==> true jshell> "abby".compareTo("acid") > 0 // "abby" > "acid" (python) $22 ==> false jshell> "abby".compareTo("ACID") < 0 $23 ==> false jshell> "abby".compareToIgnoreCase("ACID") < 0 $24 ==> true jshell> "catamaran".contains("tamar") $25 ==> true jshell> // "tamar" in "catamaran" jshell> "dumbo.html".endsWith(".html") $26 ==> true jshell> "dumbo.html".startsWith("dumbo") $27 ==> true jshell> String s = "noodle" s ==> "noodle" jshell> String t = "noodle" t ==> "noodle" jshell> s.equals(t) $30 ==> true jshell> s == t $31 ==> true jshell> String.format("(%s, %s)", 5,6); $32 ==> "(5, 6)" jshell> "" + 5 $33 ==> "5" jshell> "" + 5 + 4.6 + "cat" $34 ==> "54.6cat" jshell> "" + (5 + 4.6) + "cat" $35 ==> "9.6cat" jshell> string s = "abcdefghijklmnop" | Error: | cannot find symbol | symbol: class string | string s = "abcdefghijklmnop"; | ^----^ jshell> String s = "abcdefghijklmnop" s ==> "abcdefghijklmnop" jshell> s.indexOf('c') $37 ==> 2 jshell> s.indexOf('c', 6) $38 ==> -1 jshell> s.indexOf("jkl") $39 ==> 9 jshell> s.indexOf("jkl", 7) $40 ==> 9 jshell> s.indexOf("jkl", 11) $41 ==> -1 jshell> s.isBlank() $42 ==> false jshell> String w = " \t\t\t\t\n\n " w ==> " \t\t\t\t\n\n " jshell> w.isBlank() $44 ==> true jshell> s.length() $45 ==> 16 jshell> s.repeat(4) $46 ==> "abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop" jshell> "*".repeat(50) $47 ==> "**************************************************" jshell> x = " space " | Error: | cannot find symbol | symbol: variable x | x = " space " | ^ jshell> String x = " space " x ==> " space " jshell> x.strip() $49 ==> "space" jshell> s.lstrip() | Error: | cannot find symbol | symbol: method lstrip() | s.lstrip() | ^------^ jshell> s.stripLeading() $50 ==> "abcdefghijklmnop" jshell> //lstrip() jshell> s.stripTrailing() $51 ==> "abcdefghijklmnop" jshell> //rstrip jshell> s s ==> "abcdefghijklmnop" jshell> s.substring(5) $53 ==> "fghijklmnop" jshell> // s[5:] jshell> s.substring(2,5) $54 ==> "cde" jshell> //s[2:5] jshell> s.substring(0,3) $55 ==> "abc" jshell> //s[:3] jshell> s.toUpperCase() $56 ==> "ABCDEFGHIJKLMNOP" jshell> s.toLowerCase() $57 ==> "abcdefghijklmnop" jshell> s.SwapCase() | Error: | cannot find symbol | symbol: method SwapCase() | s.SwapCase() | ^--------^ jshell> s.swapCase() | Error: | cannot find symbol | symbol: method swapCase() | s.swapCase() | ^--------^ jshell> s s ==> "abcdefghijklmnop" jshell> s.replace("a", "A") $59 ==> "Abcdefghijklmnop" jshell> s s ==> "abcdefghijklmnop" jshell> s.replace("klmn", "cows") $61 ==> "abcdefghijcowsop" jshell> s.replace("c", "C"); $62 ==> "abCdefghijklmnop" jshell> s.replace("klmn", "cows").replace("c", "C") $63 ==> "abCdefghijCowsop" jshell> s.toUpperCase() $64 ==> "ABCDEFGHIJKLMNOP" jshell> String.valueOf(true) $65 ==> "true" jshell> String.valueOf(false) $66 ==> "false" jshell> String.valueOf(45) $67 ==> "45" jshell> String.valueOf(6.02e23) $68 ==> "6.02E23" jshell> byte b = 5 b ==> 5 jshell> String.valueOf(b) $70 ==> "5" jshell> int k = 5 k ==> 5 jshell> "" + k $72 ==> "5" jshell> Integer.toString(k) $73 ==> "5" jshell>