Tag Archives: Java-Basics

Operators in Java

Java provides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are- Arithmetic Operators Unary Operators Assignment Operator Relational Operators Logical Operators Ternary Operator Bitwise Operators Shift Operators instance of operator Precedence and Associativity Interesting Questions Lets take a… Read More »

Loops in Java

Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. Java provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition checking time. while loop: A while loop is a… Read More »

Java Identifiers

In programming languages, identifiers are used for identification purpose. In Java an identifier can be a class name, method name, variable name or a label. For example : public class Test { public static void main(String[] args) { int a = 20; } } In the above java code, we have 5 identifiers namely : Test : class name.… Read More »

Comments in Java

In a program, comments take part in making the program become more human readable by placing the detail of code involved and proper use of comments makes maintenance easier and finding bugs easily. Comments are ignored by the compiler while compiling a code. In Java there are three types of comments: Single – line comments.… Read More »

Basic Operators in Java

Java provides a rich operator environment. We can classify the basic operators in java in following groups: Arithmetic Operators Relational Operators Bitwise Operators Assignment Operators Logical Operators Let us now learn about each of these operators in details. Arithmetic Operators: Arithmetic operators are used to perform arithmetic/mathematical operations on operands. Addition (‘+’) :  Adds two… Read More »

Access Modifiers in Java

As the name suggests access modifiers in Java helps to restrict the scope of a class, constructor , variable , method or data member. There are four types of access modifiers available in java: Default – No keyword required Private Protected Public Default: When no access modifier is specified for a class , method or… Read More »

Classes and Objects in Java

Classes and Objects are basic concepts of Object Oriented Programming which revolve around the real life entities. Class A class is a user defined blueprint or prototype from which objects are created.  It represents the set of properties or methods that are common to all objects of one type. In general, class declarations can include… Read More »

Beginning Java programming with Hello World Example

The process of Java programming can be simplified in three steps: Create the program by typing it into a text editor and saving it to a file – HelloWorld.java. Compile it by typing “javac HelloWorld.java” in the terminal window. Execute (or run) it by typing “java HelloWorld” in the terminal window. Below given  program is… Read More »

Setting up the environment in Java

Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented etc. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.The latest version is Java 8. Below are the environment settings for both Linux and Windows. JVM, JRE and JDK  all three are platform… Read More »

Variables in Java

A variable is the name given to a memory location. It is the basic unit of storage in a program. The value stored in a variable can be changed during program execution. A variable is only a name given to a memory location, all the operations done on the variable effects that memory location. In… Read More »