Temperature Convert
NOW IN THIS PART U WILL LEARN HOW TO CONVERT TEMPERATURE TO FAHRENHEIT OR VICE VERSA [sourcecode=’java’] public class Temperature { public static double temp;… Read More »Temperature Convert
NOW IN THIS PART U WILL LEARN HOW TO CONVERT TEMPERATURE TO FAHRENHEIT OR VICE VERSA [sourcecode=’java’] public class Temperature { public static double temp;… Read More »Temperature Convert
Actually Interface are just like a class where it consists only constants and they
We can extend interface via interfaces
We can implement the interface via classes.
In interface needn’t use the “public” or “abstract” keywords – all methods
declared by an interface are automatically public and abstract by default.
A simple example of interface implement is given below.
[sourcecode=’java’]
public interface testInterface {
//one of the method without method body
void disp(String text);
}[/sourcecode]
For implementing this interface through normal class we follow below step:Read More »Interface Class
[sourcecode=’java’] public class Student { private static int totalStudents; // Other details omitted. // Constructor. public Student() { // Details omitted. // Automatically increment the… Read More »Static method
Switch is mostly useful while we are making any menu-driven program and we can use switch even for many other purposes. Here I’m going to… Read More »Using Switch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public static void main(String[] args) { int binary = 4; int hexadecimal = 43; //Convert the integer to binary. Stored in String. String bin = Integer.toBinaryString(binary); System.out.println(binary + " as binary: " + bin); //Convert the second integer into hex. Stored in String. String hex = Integer.toHexString(hexadecimal); System.out.println(hexadecimal + " as hex: " + hex); //To convert back, parse the String with base 2 (binary). System.out.println(bin + " as integer: " + Integer.parseInt(bin, 2)); //Hexadecimal is base-16, so pass in 16 as base. System.out.println(hex + " as integer: " + Integer.parseInt(hex, 16)); } |
Just paste these java codes in your java file .Compile and Run it . Now u will be able to easily convert the Number… Read More »Converting Number System