标签:from rect led new exp roo span ESS str
bst to dll NOT TESTED YET public Node head = null; public Node prev = null; public void inOrder(Node root){ if(root == null){ return; } inOrder(root.left); if(prev == null){ head = root; }else{ prev.right = root; root.left = prev; } prev = root; inOrder(root.right); } return head; ================= class Solution { public Node head = null; public Node prev = null; public Node treeToDoublyList(Node root) { inOrder(root); return head; } public void inOrder(Node root){ if(root == null){ return; } inOrder(root.left); if(prev == null){ head = root; }else{ prev.right = root; root.left = prev; } prev = root; inOrder(root.right); } } Global varriable which is defined after the class tag and before Method. so there are two type of Global variable 1. Instace global variable * public class GolbalVariable{ * public String username; * public String password; * } Explanation : this is called as instance variable . so on instance method you can access directly . suppose if you want to access inside statioc method then create Object of class and access it . if method is static then code to access the variable * ClassObject obj=new ClassObject();//create class Object from static method * username;//if username is static * obj.username; // if username is instance 1. static global variable * public class GolbalVariable{ * public static String username; * public static String password; * } Explanation : You can access directly with class Name
标签:from rect led new exp roo span ESS str
原文地址:https://www.cnblogs.com/tobeabetterpig/p/9490878.html