Java Tutorial

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

Command Line Arguments are parameters that are supplied to the application program at the time of invoking it for execution. We can write Java programs that can receive and use the arguments provided in the command line.

 
by Dinesh Thakur Category: Data Type

Java has a wide variety of data types from which we can choose the suitable for a particular purpose. To operate on variables from two different types of data we have to convert Both types to the same.



 
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

We use the static keyword mostly for memory management, and the keyword goes with the class itself, not with a class instance. It may be:  

• A variable, or class variable
• A method, or class method
• A block
• A nested class
• Static Variable

 
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

It is in two types. Those are,

 

1. Command line arguments

2. By using readLine() method

 
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.



 
by Dinesh Thakur Category: Data Type

Sometimes you have to work with characters that are not listed on the keyboard or with characters that have a special meaning, as symbol as a "newline." They can not be displayed directly in the source the program code, and to use them we need special techniques that will look at now.

 
by Dinesh Thakur Category: Data Type

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

 

Page 7 of 80



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.