I have two classes:
public class node { static LinkedList<Integer> nodes = new LinkedList<Integer>(); public boolean visited; public static void Main (String args []) { System.out.println("Number of nodes in network"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i=1;i<=n;i++){ nodes.add(i); } System.out.println(nodes); } and another class
public class AdjacencyList { private int n; private int density; I want to access int n from Mainmethod and assign its value to private int n in AdjacencyList class. I tried node.n (class.variable) format in a method where I can assign values but its not working out. Can anybody please help me with this?
nto bestatic.AdjacencyListclass.nfrommainand where do you want to create theAjacentList, in themain?