java tutorials

Java while

When we want to execute a block execute multiple time then we use loop.It executes until condition is true. The while executes a block of code as long as a given condition is true.

Java switch

Java switch statement is used to select one of many code blocks to be executed. How to Java switch works:

Matching each expression with case
Once it match, execute all case from where it matched.
Use break to exit from switch
Use default when expression does not match with any case

Java if else

if Statement Use the if statement to specify a block of Java code to be executed if a condition is true. if (condition) { // block of code to be executed if the condition is true } Sample program with if Write a program or WAP to find a number is greater or not. class […]

Java Comments

Java Comments can be used to help for description the code. It will never show on run time. Single-line comments It starts with two forward slashes (//). Java Multi-line Comments. More than one line comments start with /* and ends with */.

Java Type Casting or Type Conversion

Type casting is when you assign a value of one primitive data type to another type. In Java, there are two types of casting:
Widening Casting (automatically) – converting a smaller type to a larger type size

Java Variables

Variable allocates reserved memory area. char ch=’A’;//chis variable | int num=10;//num is variable | Types of Variable 1-Local Variable is declared inside the method. 2-Instance Variable is declared inside the class but outside the method. 3- Static variable is declared as with static keyword.

Java Keywords

A keyword is a reserved word. You cannot use it as a variable name, constant name etc. Ex: int, char, float, for, while etc.

Java Operators

Java Operators is a symbol which is used to perform operations. Java Operators has defined such as unary operator, arithmetic operator, relational operator, shift operator, bitwise operator, ternary operator and assignment operator. Java Arithmetic Operators Java Arithmetic operators are used to perform common mathematical operations. Operator Name Description Example + Addition Adds together two values […]

Java Data Types

Data types in Java:1- Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double.
2- Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.

First program in Java

Open an editor like: Notepad, Sublime etc and write. Go to command prompt: (javac for compile and java for run).

1 9 10 11 12