Why Main method in java is static?

The method is static because otherwise there would be ambiguity: which constructor should be called? Especially if your class looks like this: Should the JVM call new JavaClass(int)? What should it pass for x? If not, should the JVM instantiate JavaClass without running any constructor method? I…

JAVA class overview

JAVA class standerd. It should start with Capital letter and in CamelCase (which means first letter of every word should start with capital letter. class name shouldn't have Blank space, if you don't use that standard then this will not give any error, but its for simplicity so you can easily…

Switch statement in java

Switch statement is same as else if statement. In switch statement only 1 condition will be true and that will be executed. Switch is easier than else if statement. In else if statement we wrote condition in every block like And so on. But in switch statement we use cases. For example This is syntax…

Nested if statement in java

Is nested because you have conditions evaluated within other conditions, that is, dependent on previous conditions. If you want to be literal about it, the scope of cond2 in the second case is literally nested in the scope of cond1. This is not true in the first form. where the else part is optional…

Else if statement in Java

If statement is used to single condition. But if we want to validate multiple condition then we can use else if. If else is used if we have multiple condition and choose 1 condition at a time. For example, if we want to validate that, if a = 0 then print Zero, if a = 1 then print one, if a = 2 then…

If statement in java, how to use

If statement is used when we want to check a condition. We check a condition to prevent our program from sudden crash. Mostly our app crash due to lack of validation. If we validate value before using, then we will not face any error or exception. For example, if we want to device two values, but…

Page 11 Of 15

LearnPainLess On Instagram

Get The Best Of All Hands Delivered To Your Inbox

Subscribe to our newsletter and stay updated.