Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JGraph problem

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    Default JGraph problem

    private static Graph<String, Integer> map;

    public static void makeGraph() {
    System.out.println("Graph building started...");
    for (int i = 0; i < size; i++) {
    for (int j = i + 1; j < size; j++) {
    if (linkable(usable[i], usable[j])) {
    System.out.println(usable[i] + ": " + usable[j]); <=== it does print out the String in i and j
    map.addEdge(usable[i], usable[j]); <===== error here
    System.out.println("Graph have been built");
    //usable is an array of containing String
    //linkable test if they are related

    I keep getting an java.lang.NullPointerException when i run the code. Need help, 1st time using JGraph

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,465 Times in 2,416 Posts

    Default Re: JGraph problem

    What variable has a null value? Print out the variables on the line with the error.
    Why doesn't the variable have a valid non-null value? Backtrack in the code to see.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM

Tags for this Thread