Java Tutorial

by Dinesh Thakur Category: Data Type
  1. When the variable is declared within the method, block and constructor then the variable is treated as local variable.
  2. Local variable must be initialized before you call it otherwise it generates compile time error.
  3. Same local variable can be declared in two different blocks.
  4. Local variable never use any access specifier. It only takes the default access specifier.
  5. Local variable can never be declared through any access specifier except default access specifier.
 
by Dinesh Thakur Category: Data Type

This Java byte Example shows how to use Java primitive byte variable inside a java class. The byte is a 8 bit signed type ranges from –128 to 127. The syntex For Declare byte varibale is byte <variable name> = <default value>;



 
by Dinesh Thakur Category: Data Type

This Java boolean Variable Example shows how to use Java boolean variable inside a java class. The boolean data type which can have only two values, true or false.



 
by Dinesh Thakur Category: Data Type

This Convert int to string java example shows how to convert int to String in Java.



 
by Dinesh Thakur Category: Data Type

This Swap Numbers Without Using Third Variable Java Example shows how to exchange numbers without using third variable using java. i.e. if the input is n1 100 and n2 200 then after swaping output will be n1 is 200 and n2 is 100. You should not use any temporary variable to swap the numbers.



 
by Dinesh Thakur Category: Data Type

This Swap Numbers Java Example program prints exchange number i.e. if the input is n1 is 100 and n2 is 200 then after swaping output will be n1 is 200 and n2 is 100. You should use any temporary variable to swap the numbers.

 
by Dinesh Thakur Category: Data Type

This Reverse Number using Java program prints reverse number using numeric operations i.e. if the input is 564 then output will be 465. we can see after reversing the integer is print the integer digits in reverse order.

 
by Dinesh Thakur Category: Data Type

This JavaInterfaceExample shows, An interface is a blueprint of a class. its functions should be public and abstract. We use the interface Keyword to define an interface. if a class implementing an interface should use the implements keyword as we see in our example class JavaInterface implements InterfaceExample . No need to creating objects for an interface. Interfaces don't have constructors as they can't be initiated. An Interface can be extends by one or more interfaces.

 
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

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 LargestandSmallestnumber shows how to Find Largest and Smallest Number in an Array Using Java Example

 
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

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 PerimeterofCircleExample shows how to Calculate Perimeter of Circle using 2*pi*r. where r is a radius of a circle.

 
by Dinesh Thakur Category: Data Type

In the Following example AreaofCircleExample shows how to Calculate Area of Circle using pi*r*r. where r is a radius of a circle.

 
by Dinesh Thakur Category: Data Type

Java's built-in data types called primitive data types. The primitive data types are int, byte, short, long, float, double, char, and boolean. A variable of any of these data types is called a primitive variable. We explain primitive data types in more detail as follows:



 
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

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

Automatic memory management, also known as automatic garbage collection, is the practice of allowing the language implementation to keep track of used and unused memory, freeing the programmer from this burden.

 
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.

 

Page 4 of 40



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.