oop - can we access non-static class from main() method in java? -


in if make node class non-static , main method able access it.

class linkedlist  {     node head;    static class node {     int data;     node next;     node(int d)  { data = d;  next=null; } // constructor }   public static void main(string[] args) { ..............} } 

yes, can access node class main method, if instantiate object class. can that:

class linkedlist {      node head;      class node {         int data;         node next;         node(int d)  { data = d;  next=null; } // constructor     }       public static void main(string[] args) {         //instantiate object         linkedlist.node node = new linkedlist().new node(0);     } } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -