Void methods cannot return a value

前端 未结 10 2185
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 01:38

I\'m following the CS106A lectures online. I\'m going through the code on Lecture 12, but it\'s giving me errors in Eclipse.

This is my code. It seems the error is beca

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 02:05

    You need to declare your method outside of the main

    public class YourClass
    {
        public static void main(String... args)
        {
    
        }
    
        public char yourMethod()
        {
    
        }
    }
    

    the string args bit is so when you run it through command line you can send values (as strings)

    >java myprogram var1 var2 ....
    

提交回复
热议问题