8 Answers
New AnswerYou are using methods when you use System.out.print( ); & System.out.println( ); There are two basic types of methods: • Build-in methods are part of the compiler package, such as System.out.println( ); & System.exit(0); • User-defined methods are created by you, the programmer. These methods take-on names that you assign to them and perform tasks that you create.
I don't actually understand your question. But what I know is that, in most of the programming languages every statement must be wrapped inside a method or function or maybe a class. You can not execute anything without using method. Because most of the programming languages starts with main method.
I dont really understand the question, but Maybe you can, check this out. public class Program { static{ System.out.println("surprise ! :D"); } public static void main(String[] args) { } }
Thats a static block You were asking about command without method right ? My example show that you can execute a block of code with out any method. A static block will run when the class is loaded. Sorry for not give much explaination :D
Thanks Raj, now I understand that a minimal program must contain at least one class and a function/method.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message