<jupyter_start><jupyter_text>Jshell vs JavaWe are using jshell, jshell has mostly the same behavior as Javabut because it's interactive it can do more  Re-defining records or variablesyou can define a record or a variable several times, jshell will use the most recent one<jupyter_code>record Point(int x, int y) { }
var p = new Point(2, 3);

record Point(int x, int y) {
  int distanceInX(int anotherX) {
    return Math.abs(x - anotherX);
  }
}
var p = new Point(2, 3);
System.out.println(p.distanceInX(0));<jupyter_output><empty_output><jupyter_text>and you can also directly write a method outside a record,it will act as a static method<jupyter_code>void hello() {
  System.out.println("hello !");
}
hello();<jupyter_output><empty_output><jupyter_text>Special commandsThere are a bunch of special commands that starts with '/'you can use /help if you want to know more By example, you have also a list of the packages automatically imported<jupyter_code>/import<jupyter_output><empty_output><jupyter_text>and you can import new package dynamically<jupyter_code>import java.util.zip.*<jupyter_output><empty_output><jupyter_text>note that unlike import in Python or include in C, Java import doesn't load any code,it says that is you search a name of a type, here are the packages to search.If a type appear in more than one package, an error will be reported and you willhave to import the type explicitly (without any *)by example, to import a List of the package java.util<jupyter_code>import java.util.List;<jupyter_output><empty_output><jupyter_text>Entry PointWith jshell, the code is executed from top to bottomIn Java, when executing `java Hello`, the launcher looks for a static methodnamed `main` that- must be visible from the outside (`public`)- takes an array of String (`String[]`) and- returns no value (`void`)<jupyter_code>record Hello() {
  public static void main(String[] args) {
    System.out.println("Hello !");
  }
}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08768373035985809, 'fraction_numerical': 0.002534211860111505, 'mean_word_length': 5.60200668896321, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '50117', 'license': 'MIT', 'n_tokens_mistral': 601, 'n_tokens_neox': 588, 'n_words': 240, 'path': 'jupyter/chapter03-jshell_vs_java.ipynb', 'repo_name': 'cynthiaZV/java-guide-1', 'size': '1973'}