Changes

Jump to navigation Jump to search
172 bytes added ,  08:23, 28 April 2022
m
Line 3: Line 3:  
===With apt===
 
===With apt===
 
  <nowiki>sudo apt-add-repository ppa:webupd8team/java
 
  <nowiki>sudo apt-add-repository ppa:webupd8team/java
                                        sudo apt-get update
+
                                          sudo apt-get update
                                        sudo apt-get install oracle-java8-installer</nowiki>
+
                                          sudo apt-get install oracle-java8-installer</nowiki>
    
Also ensure your JAVA_HOME variable has been set to:
 
Also ensure your JAVA_HOME variable has been set to:
Line 975: Line 975:  
}</source>
 
}</source>
   −
=== Try with resources (similar to python with) ===
+
===Try with resources (similar to python with)===
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
 
import java.util.Scanner;
 
import java.util.Scanner;
Line 987: Line 987:  
     // this will throw an exception but scanner will be closed
 
     // this will throw an exception but scanner will be closed
 
     }
 
     }
 +
}
 +
</syntaxhighlight>
 +
 +
=== catch multiple exceptions ===
 +
<syntaxhighlight lang="java">
 +
try {
 +
    // code
 +
} catch (IOException | SQLException ex) {
 +
    ex.printStackTrace();
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Navigation menu