I\'m trying to throw an exception in my code like this:
throw RuntimeException(msg);
But when I build in NetBeans I get this error:
<
using new keyword we always create a instance (new object) and throwing it , not called a method
throw new RuntimeException("Your Message");
You need the new in there. It's creating an instance and throwing it, not calling a method.
int no= new Scanner().nextInt(); // we crate an instance using new keyword and throwing it
using new keyword memory clean [because use and throw]
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//do your work here..
}
}, 1000);