Category: java-basics
while Loop in Java With Examples
do-while loop in Java With Examples
Private Methods in Java Interface
JShell in Java
The Java Shell or JShell is an interactive command line tool for learning the Java programming language and to test Java code. JShell is a Read-Evaluate-Print Loop (REPL), which evaluates declarations, statements, and expressions as they are typed and immediately shows the results. This way you don’t need to write…
Java var Type (Local Variable Type Inference)
In this post we’ll discuss a feature called local variable type inference which is included in Java 10. A new reserved type name “var” is added in Java to define and initialize local variables. Note that var is not a keyword, it’s a reserved type name. So your existing variable…
Method Overloading in Java
In Java you can have two or more methods having the same name with in the same class provided their arguments differ in either type or number. These types of methods are called overloaded methods and the process is known as method overloading in Java. Method overloading in Java –…
super in Java With Examples
Super keyword in Java is used to refer to the immediate parent class of the sub class. You can use super keyword in Java in following ways- You can invoke the constructor of the parent class, doing that using super makes your code more compact and classes are better encapsulated.…
static in Java With Examples
Static keyword in Java is used to create variables and methods that are associated with the class rather than with any object of the class. Table of contents Static in Java static variables in Java Static variables usage static methods in Java static method access restrictions Static method usage Static…
Java Ternary Operator With Examples
In the post conditional operators in Java we talked about the Conditional-AND and Conditional-OR operators, here we’ll talk about another conditional operator known as ternary operator in Java (?:). Ternary operator uses three operands thus the name ternary operator and it can be used in place of if-else statement or…