title: How to make getWeight() return the weight of this edge
body: <pre><code>    import java.util.*;
  
  
  class Graph{
    class Edge{
      int v,w;
      public Edge(int v,int w){
          this.v=v; this.w=w;
      }
      @Override
      public String toString(){
          return "("+v+","+w+")";
      }
  }
  List&lt;Edge&gt; G[];
  public Graph(int n){
      G=new LinkedList[n];
      for(int i=0;i&lt;G.length;i++)
          G[i]=new LinkedList&lt;Edge&gt;();
  }
  boolean isConnected(int u,int v){
      for(Edge i: G[u])
          if(i.v==v) return true;
      return false;
  }
  void addEdge(int u,int v,int w)
  {
  
      G[u].add(0,new Edge(v,w));
      G[v].add(0,new Edge(u,w));
  }
  public int getWeight(int u, int v)
  {
      int w;
      return w;
  }
  </code></pre>
  
  <p>This part right above ^^^^. I'm trying to make it so that the code returns the correct number associated with the two numbers already input. For example g.getWeight(6,3) should return 13 since that is the weight in the graph for those two numbers.</p>
  
  <pre><code>@Override
  public String toString(){
      String result="";
      for(int i=0;i&lt;G.length;i++)
          result+=i+"=&gt;"+G[i]+"\n";
      return result;
  }
  }
  
  public class GraphEx
  {
    public static void main(String[] args) 
    {
      Graph g=new Graph(10);
      g.addEdge(1,2,38);
      g.addEdge(1,5 ,19);
      g.addEdge(1,3 ,35);
      g.addEdge(1,4 ,11);
      g.addEdge(4,3,27);
      g.addEdge(3,6,13);
      g.addEdge(3,5,28);
      g.addEdge(5,6,26);
  
  
  
      System.out.println(g);
      g.getWeight(6,3);
  }
  }
  </code></pre>
  
  <p>The error the code as it currently stands gives is "variable w might not have been initialized"</p>