今天在编译 Java : :
لا يمكن الوصول إلى مثيل ملحق من نوع printfromtailtohead. يجب تأهيل التخصيص مع مثيل مغلق
من النوع printflistfromtailtohead (egxnew a () حيث x هو مثيل قائمة printfromtailtohead).
: :
الطباعة العامة printfromtailtailtohead {public static void main (string [] args) {listNode One = new listNode (1) ؛ listNode two = new listNode (2) ؛ listNode three = new listNode (3) ؛ One.next = two.next = three ؛ arraylist <nteger> relation = printflaithead (one) ؛ النتيجة) ؛} class listNode {public int val ؛ public listnode next ؛ public listnode () {} public listNode (int val) {this.val = val ؛}} ArrayList static static public <Steger> printfromtailtohead (listnode) {stack.push (listnode.val) ؛ listNode = listNode.next ؛} ArrayList <integer> ArrayList = new ArrayList <integer> () ؛: :
代码中 , 我的 listnode 类是定义在 printlistfromtailtohead 类中的内部类。listnode 内部类是动态的内部类 , 而我的 main 方法是 方法是 方法是 静态的。
就好比静态的方法不能调用动态的方法一样。
: :
: :
将内部类 ListNode 定义成静态 ثابت 的类。
: :
将内部类 ListNode 在 printlistfromtailtohead 类外边定义。
: :
: :
الطباعة العامة printfromtailtailtohead {public static void main (string [] args) {listNode One = new listNode (1) ؛ listNode two = new listNode (2) ؛ listNode three = new listNode (3) ؛ One.next = two.next = three ؛ arraylist <nteger> relation = printflaithead (one) ؛ النتيجة) ؛} فئة ثابتة listNode {public int val ؛ public listnode next ؛ public listnode () {} public listNode (int val) {this.val = val ؛}}: :
الطباعة العامة printflistfromtailtohead {public static void main (string [] args) {listNode One = new listNode (1) ؛ listNode two = new listNode (2) ؛ listNode three = new listNode (3) ؛ One.next = two ؛ next = three ؛} static static static <integer> prinistr مكدس <integer> () ؛ بينما (listNode! = null) {stack.push (listnode.val) ؛ listNode = listNode.next ؛} ArrayList <integer> arraylist = new arraylist <integer> () ؛ Val ؛ Public ListNode التالي ؛ Public ListNode () {} Public ListNode (int val) {this.val = val ؛}}以上所述是小编给大家介绍的 java 解决 لا يوجد مثيل ملحق من نوع printlistfromtailtohead يمكن الوصول إليه 问题的两种方案 , 希望对大家有所帮助。