diff --git a/GenericMethod1.class b/GenericMethod1.class new file mode 100644 index 0000000..b92e58b Binary files /dev/null and b/GenericMethod1.class differ diff --git a/GenericMethod1.java b/GenericMethod1.java new file mode 100644 index 0000000..613240d --- /dev/null +++ b/GenericMethod1.java @@ -0,0 +1,20 @@ +public class GenericMethod1 +{ + public static void main(String[] args) + { + Integer[] intArray = {1, 2 , 3 ,4 ,5}; + String[] stringArray = {"Hello", "Adi", "!"}; + System.out.print("Integer Array:"); + printArray(intArray); + System.out.print("String Array:"); + printArray(stringArray); + } + public static void printArray(T[] arr) + { + for(T element : arr) + { + System.out.print(element + " "); + } + System.out.println(); + } +} diff --git a/GenericMethod2.class b/GenericMethod2.class new file mode 100644 index 0000000..1f25bde Binary files /dev/null and b/GenericMethod2.class differ diff --git a/GenericMethod2.java b/GenericMethod2.java new file mode 100644 index 0000000..28d9e19 --- /dev/null +++ b/GenericMethod2.java @@ -0,0 +1,19 @@ +public class GenericMethod2 +{ + public static > T findMax(T x, T y) + { + return x.compareTo(y) > 0 ? x : y; + } + + public static void main(String[] args) + { + Integer maxInt = findMax(5,10); + System.out.println("Maxim7um of 5 and 10 is: " +maxInt); + + Double maxDouble = findMax(3.5, 7.8); + System.out.println("Maximum of 3.5 and 7.8 is: " +maxDouble); + + String maxString = findMax("apple", "banana"); + System.out.println("Maximum of 'apple' and 'banana' is: " +maxString); + } +} \ No newline at end of file diff --git a/MovieBook.java b/MovieBook.java index c84dde1..3822778 100644 --- a/MovieBook.java +++ b/MovieBook.java @@ -1,3 +1,4 @@ +//write a java program for inter thread communication using wait(), notify(), notifyall() class TotalEarnings extends Thread { int total = 0; diff --git a/TestSynchronization2.java b/TestSynchronization2.java index ae79eea..94b002d 100644 --- a/TestSynchronization2.java +++ b/TestSynchronization2.java @@ -1,3 +1,4 @@ +//Write a java program for demonstrating thread synchronization class Table { synchronized void printTable(int n) diff --git a/outputs/instructions.txt b/outputs/instructions.txt new file mode 100644 index 0000000..e69de29 diff --git a/outputs/program 8 (b) generic.png b/outputs/program 8 (b) generic.png new file mode 100644 index 0000000..9c08a42 Binary files /dev/null and b/outputs/program 8 (b) generic.png differ diff --git a/outputs/program 8 (c) generic.png b/outputs/program 8 (c) generic.png new file mode 100644 index 0000000..223f8df Binary files /dev/null and b/outputs/program 8 (c) generic.png differ