You are here:   HomeJava Programming
by Dinesh Thakur Category: Data Type

A variable is a place in memory where we can store a value. The Java programming language defines the following kinds of variables :



 
by Dinesh Thakur Category: Data Type

Operator is a symbol that represents some operation that can be performed on data. The operators are applied to operands (onto which processing is desired). These operands can be literals, variables etc. The operators supported by Java are as follows:



 
by Dinesh Thakur Category: Data Type

In the Following example OddorEvenNumbers use mod operator to check if the number is even or odd. If the number divided by 2 and the reminder is 0 then number is even, otherwise the number is odd.

 
by Dinesh Thakur Category: Data Type

It is in two types. Those are,

 

1. Command line arguments

2. By using readLine() method

 
by Dinesh Thakur Category: Data Type

The Exit statement allows you to exit prematurely from a block of statements in a control structure from a loop, or even from a procedure. Suppose you have a For…….Next loop that calculates the square root of negative numbers can't be calculated ( the Sqr() function generates a runtime error,)

 
by Dinesh Thakur Category: Data Type

This Java Factorial Example shows how to finds factorial of a given number using Java. Entered number is checked first if its negative then an error message is printed.



 
by Dinesh Thakur Category: Data Type

In the Following example AreaofRectangleExample shows how to Calculate Area of Rectangle is length * width.

 
by Dinesh Thakur Category: Data Type

In the Following example LargestandSmallestnumber shows how to Find Largest and Smallest Number in an Array Using Java Example



 
by Dinesh Thakur Category: Data Type

This JavaFactorialUsingRecursion Example shows shows how to generate factorial of a given number using recursive function. Recursive are the function which calling method itself. the java recursion factorial example demonstrate recursive function call to find factorial. In mathematics, factorial is defined as n! = n*(n-1)...2*1. e.g. If we want to calculate factorial of 10 , then its factorial value is (10*9*8*7*6*5*4*3*2*1) = 3628800.



 
by Dinesh Thakur Category: Data Type

1. When the variable is declared outside the method, block, and constructor without using any modifier then it is treated as instance variable.
2. If the instance variable is not initialized then it takes the default value of the data type when the object is constructed.
3. Instance variable can use any access specifier.
4. It is accessed within the static method through the object of the class and within the non-static method and constructor directly without creating any object within the class, but outside the class non-static method and constructor invoke instance variable through objects.
5. Instance variable is also known as object level variable as for every instance the value of instance variable is newly initialized.



 

Page 7 of 80

What's New and Popular