Sorted by:  

Create an Abstract Class in Java

An abstract class in Java is a class that contains one or more abstract methods, which are simply method declarations without a body — that is, without executable code that implements the class or method [more…]

How to Use the javac Command

The javac command in Java compiles a program from a command prompt. It reads a Java source program from a text file and creates a compiled Java class file. The basic form of the [more…]

Methods and Method Declaration in Java

A method in Java is a block of statements that has a name and can be executed by calling (also called invoking) it from some other place in your program. Along with fields, methods are one of the two elements [more…]

What Are Objects in Java Programming?

Object-oriented programming is a type of computer programming — such as Java — based on the premise that all programs are essentially computer-based simulations of real-world objects or abstract concepts [more…]

What Is the Life Cycle of an Object in Java?

One topic that’s important to know about when you work with object-oriented programming in Java is the life cycleof an object. How objects are born, live their lives, and die is important. In Java, the [more…]

How Operators Work in Java

An operator in Java is a special symbol or keyword that’s used to designate a mathematical operation or some other type of operation that can be performed on one or more values, called [more…]

How to Use a Package Statement in Java

The package statement identifies the package that a Java program belongs to. If your program does not include a package statement, the program belongs to the [more…]

Polymorphism in Java

Polymorphism is a fancy computer science term that refers to Java’s ability to use base-class variables to refer to subclass objects, keep track of which subclass an object belongs to, and use overridden [more…]

What Is Recursion in Java Programming?

Recursion is a basic programming technique you can use in Java, in which a method calls itself to solve some problem. A method that uses this technique is [more…]

Reference Types in Java

A reference type is a data type that’s based on a class rather than on one of the primitive types that are built in to the Java language. The class can be a class that’s provided as part of the Java API [more…]

Shadowed Classes or Variables in Java

Shadowing refers to the practice in Java programming of using two variables with the same name within scopes that overlap. When you do that, the variable with the higher-level scope is hidden because the [more…]

How Statements Are Used in Java

Unlike most programming languages, Java doesn’t use statements as its fundamental unit of code. Instead, it gives that honor to the class. However, every class must have a body, and the body of a class [more…]

What Is the Static Keyword in Java?

In Java, a static member is a member of a class that isn’t associated with an instance of a class. Instead, the member belongs to the class itself. As a result, you can access the static member without [more…]

Switch Statements in Java

A switch statement is useful when you need to select one of several alternatives based on the value of an integer, a character, or a Stringvariable. The basic form of the [more…]

How to Use the Java Keyword this

The keyword this in Java refers to the current class instance. For example, if a class defines a method named Calculate, you can call that method from another method within the same class like this: [more…]

Try Statements in Java

A try statement is used to catch exceptions that might be thrown as your program executes. You should use a try statement whenever you use a statement that might throw an exception That way, your program [more…]

How to Use While Statements in Java

A while statement in Java programming creates a loop that executes continuously as long as some conditional expression evaluates to true. The basic syntax is this: [more…]

Java's ArrayList Class

The ArrayList package (Package: java.util) in Java lets you create and maintain a special type of collection object: an array list. An array list is similar to an array but averts many of the most common [more…]

Use Array Lists in Java

To create an array list in Java, you declare an ArrayList variable and call the ArrayList constructor to instantiate an ArrayList object and assign it to the variable: [more…]

Arrays Class in Java

The Arrays class (package: java.util) provides a collection of static methods that are useful for working with arrays. Because the Arrays class provides only static methods, it has no constructors. [more…]

Increment and Decrement Operators in Java

Increment (++) and decrement (--) operators in Java programming let you easily add 1 to, or subtract 1 from, a variable. For example, using increment operators, you can add 1 to a variable named [more…]

What Is Inheritance in Java?

Inheritance refers to a feature of Java programming that lets you create classes that are derived from other classes. A class that’s based on another class [more…]

What Is an Initializer in Java?

An initializer is a line of code (or a block of code) placed outside any method, constructor, or other block of code. Initializers are executed whenever an instance of a class is created, regardless of [more…]

Integer Data Types in Java

An integer is a whole number — that is, a number with no fractional or decimal portion. Java has four integer types, which you can use to store numbers of varying sizes. [more…]

What Is an Interface in Java ?

An interface in Java is similar to a class, but the body of an interface can include only abstract methods and final fields (constants). A class implements [more…]


Sign Up for RSS Feeds

Computers & Software

Inside Sweepstakes

Win $500. Easy.