#Help with Loop

3 messages · Page 1 of 1 (latest)

hushed compass
#

Looking to get understanding of why something works in one place but doesn't work in another.

        int maximum = 0;
        for (int i = 0; i < g.nodeList.size(); i++)
            // Printing and display the elements in ArrayList
            if (maximum < g.nodeList.get(i).getOutgoingEdges().size())
                maximum = g.nodeList.get(i).getOutgoingEdges().size();
                String Test = g.getNodeList().size();
        System.out.println("Node "+ Test + " has the most outgoing edges (" + maximum + ").\n");
        
        for(Node name : g.getNodeList()) {
            System.out.println(name.getAbbrev());
            System.out.println(name.getOutgoingEdges().size());
        }

why cant I call name.getAbbrev() and place that in my String Test?

sonic shoreBOT
#

This post has been reserved for your question.

Hey @hushed compass! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.