added till 8th b and c
This commit is contained in:
BIN
GenericMethod1.class
Normal file
BIN
GenericMethod1.class
Normal file
Binary file not shown.
20
GenericMethod1.java
Normal file
20
GenericMethod1.java
Normal file
@@ -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 <T> void printArray(T[] arr)
|
||||
{
|
||||
for(T element : arr)
|
||||
{
|
||||
System.out.print(element + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
BIN
GenericMethod2.class
Normal file
BIN
GenericMethod2.class
Normal file
Binary file not shown.
19
GenericMethod2.java
Normal file
19
GenericMethod2.java
Normal file
@@ -0,0 +1,19 @@
|
||||
public class GenericMethod2
|
||||
{
|
||||
public static <T extends Comparable<T>> 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);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
//write a java program for inter thread communication using wait(), notify(), notifyall()
|
||||
class TotalEarnings extends Thread
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//Write a java program for demonstrating thread synchronization
|
||||
class Table
|
||||
{
|
||||
synchronized void printTable(int n)
|
||||
|
||||
0
outputs/instructions.txt
Normal file
0
outputs/instructions.txt
Normal file
BIN
outputs/program 8 (b) generic.png
Normal file
BIN
outputs/program 8 (b) generic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
BIN
outputs/program 8 (c) generic.png
Normal file
BIN
outputs/program 8 (c) generic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Reference in New Issue
Block a user