ArrayList list=new ArrayList ();
HashSet set=new HashSet ();
class finalParameter {
public static void example( final int parameter ) {
parameter = 4; //attempting to reassign a value to a parameter throws an error
}
}
public class switchExample {
int score = 4;
public static void main(String args[]) {
switch (score) {
case 1:
system.out.println("Score is 1");
break;
case 2:
system.out.println("Score is 2");
break;
default:
system.out.println("Default Case");
}
}
}
StringWriter writer = new StringWriter () ;
IOUtils.copy (inputStream, writer, encoding) ;
String theString = writer.toString () ;
// NB: does not close inputStrem, you’ll have to use try-with-resources for that
String theString = IOUtils.toString (inputStream, encoding) ;
// create our uncaught exception handler
Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread th, Throwable ex) {
System.out.println("Uncaught exception: " + ex);
}
};
// create another thread
Thread otherThread = new Thread() {
public void run() {
System.out.println("Sleeping ...");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("Interrupted.");
}
System.out.println("Throwing exception ...");
throw new RuntimeException();
}
};
// set our uncaught exception handler as the one to be used when the new thread
// throws an uncaught exception
otherThread.setUncaughtExceptionHandler(handler);
// start the other thread - our uncaught exception handler will be invoked when
// the other thread throws an uncaught exception
otherThread.start();