You are here:   HomeJava Programming
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 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

The static modifier is associated only with methods and variables, not classes. The static modifier is used to specify variables that can only be declared once. Static methods are used to specify methods that should not be overridden in subclasses.

 
by Dinesh Thakur Category: Data Type

Variables are useful when you need to store information that can be changed as program runs. However, there may be certain situations in the program in which the value of variable should not be allowed to modify. This is accomplished using a special type of variable known as final variable. The final variable also called constant variable. It is a variable with a value that cannot be modified during the execution of the program.



 
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

When the block is declared without using any modifier, then it is treated as the non-static block is first executed before the constructor is executed. Non-static block directly access the static variable and instance variable.

 
by Dinesh Thakur Category: Data Type

The scope of a variable specifies the region of the source program where that variable is known, accessible and can be used. In Java, the declared variable has a definite scope. When a variable is defined within a class, its scope determines whether it can be used only within the defined class or outside of the class also.



 
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 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
  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.
 

Page 9 of 80

What's New and Popular