lahasong.blogg.se

How to make a computer program using java
How to make a computer program using java





how to make a computer program using java

The code inside the parentheses denotes the inputs of the method or what the method expects to receive from whomever using it. The curly braces again describe where this part of the program starts and ends. Next to main we have a left parenthesis some code and a left parenthesis followed by the curly braces. In this case we do not want to produce anything so we state "void" so the computer knows not to be expecting anything at the end of the instruction. The last word described what sort of object the method produces. The specific details of word requires a deeper knowledge to fully understand so it the author will leave it up to the reader to investigate thing more on their own to gain this understanding. The next word is optional and describes when the method can be used. The first word describes who can use the method, and since this is the main method it must be available for everyone to use so it says "public."

how to make a computer program using java

These words describe specific attributes of the method. In front of the main method's name are three words. Since there are no instructions within main right now, running the program will cause nothing to happen. This is because when a java program is run it the first thing a computer looks for is a method named "main" and follows out all the instructions within that method. When a class contains a "main" method it allows a program to be executed.

how to make a computer program using java

The "main" method of a class is quite literally the main instruction of a program. What we just wrote is the "main" instruction, or method, of our program. Your program should now look like the picture. Inside your file type "class MyFirstProgram ".ģ.







How to make a computer program using java