Java Tutorials

Java Program on Generic Classes 0

Java Program on Generic Classes

Program 1 package dataflair; import java.util.*; class MyClass<T> { T n; MyClass(T n) { this.n=n; } public String toString() { return (” “+n); } } public class TestMain { public static void main(String[] args)...

Java Program on Maxvalue Minvalue type size 0

Java Program on Maxvalue Minvalue type size

program 1 package dataflair; public class TestVariables { public static void main(String[] args) { System.out.println(“Byte Details”); System.out.println(Byte.TYPE); System.out.println(Byte.SIZE); System.out.println(Byte.MAX_VALUE); System.out.println(Byte.MIN_VALUE); System.out.println(“Short Details”); System.out.println(Short.TYPE); System.out.println(Short.SIZE); System.out.println(Short.MAX_VALUE); System.out.println(Short.MIN_VALUE); System.out.println(“Integer Details”); System.out.println(Integer.TYPE); System.out.println(Integer.SIZE); System.out.println(Integer.MAX_VALUE); System.out.println(Integer.MIN_VALUE); System.out.println(“Long Details”);...

Java Program on User Define Wrapper Classes 0

Java Program on User Define Wrapper Classes

Program 1 package dataflair; public class MyClass { private byte n; public static final int SIZE=8; public static final String TYPE=”byte”; public static final int MAX_VALUE=127; public static final int MIN_VALUE=-128; public MyClass() {...

Java Program on Wrapper Classes 0

Java Program on Wrapper Classes

Program 1 package dataflair; public class TestMain { public static void main(String[] args) { //int a=500; // Integer I=new Integer(500); //Boxing // System.out.println(I); // Integer I1=800; //Autoboxing // // Unboxing Integer I=new Integer(130); int...

Java Program on Character Wrapper Class 0

Java Program on Character Wrapper Class

Program 1 package dataflair; public class TestCharacter { public static void main(String[] args) { // Character C1=new Character(‘A’); // Character C2=97; // System.out.println(C1); // System.out.println(C2); // System.out.println(Character.isLetter(‘A’)); //true // System.out.println(Character.isLetter(‘a’)); //true // System.out.println(Character.isLetter(65)); //true...

Java Program on Wait Notify in Multithreading 0

Java Program on Wait Notify in Multithreading

Program 1 package dataflair; import java.util.ArrayList; public class MyThread extends Thread { int sum=0; public void run() { synchronized(this) { System.out.println(“This is MyThread Thread Starts”); int i; for(i=1;i<=1000;i++) { sum=sum+i; } this.notify(); System.out.println(“This is...

Java Program on Block Synchronization 0

Java Program on Block Synchronization

Program 1 // Outer resource method package dataflair; public class MyTable { void showTable(int n) { System.out.println(“Data Flair Free Coruse”); System.out.println(“Wel come you all in Data Flair Free Coruse”); synchronized(this) { try { int...

Java Program on Priority of Thread 0

Java Program on Priority of Thread

Program 1 package dataflair; public class TestMain { public static void main(String[] args) { System.out.println(“This is Main Thread: “); System.out.println(“Main Thread Priority: “+ Thread.currentThread().getPriority()); ChildThread1 mt1=new ChildThread1(); ChildThread2 mt2=new ChildThread2(); System.out.println(“Child 1 Thread Priority:...

Java Program on Runnable Interface in Multithreading 0

Java Program on Runnable Interface in Multithreading

Program 1 package dataflair; public class MyThread implements Runnable { public void run() { try { int i; for(i=1;i<=10;i++) { System.out.println(i); Thread.sleep(1000); } } catch(InterruptedException e) { System.out.println(e); } } } Program 2 package...