added type parameter

This commit is contained in:
EAlexa 2020-04-07 16:01:30 +02:00
parent 31d57c0471
commit 7ef06c0b26

View File

@ -108,7 +108,7 @@ class Graph<E extends Comparable<E>> {
public class ConnectedComponent { public class ConnectedComponent {
public static void main(String[] args) { public static void main(String[] args) {
Graph graphChars = new Graph(); Graph<Character> graphChars = new Graph<>();
// Graph 1 // Graph 1
graphChars.addEdge('a', 'b'); graphChars.addEdge('a', 'b');
@ -123,7 +123,7 @@ public class ConnectedComponent {
graphChars.addEdge('w', 'w'); graphChars.addEdge('w', 'w');
Graph graphInts = new Graph(); Graph<Integer> graphInts = new Graph<>();
// Graph 2 // Graph 2
graphInts.addEdge(1, 2); graphInts.addEdge(1, 2);