I'm a fledgling programmer for the first year. This is a collection of personal notes that have been organized and published for review purposes. Please note that there is a high possibility that you are wrong.
Hello World!
public class Main{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
--Just output the string "Hello World!". It is called "the most famous program in the world". ――At first, remember that you write it like this.
public class Main{
public static void main(String[] args){
//Write the process to be executed here
}
}
--The structure is that the class is on the outside and the method is on the inside. --Basically, write in order from the outside to the inside
//Comment here
/*
Comment here
*/
--/ // is recognized as a comment and is not processed as a program -The part surrounded by / \ * and \ * / is also recognized as a comment (multiple lines are possible)
Roughly speaking, the contents of the method are the following four.
public void sample(){
//declare
String message = "";
int numberA = 1;
int numberB = 3;
int bumberC = 0;
//calculate
numberC = numberA + numberB;
//Control what to do
if( numberC > 2 ){
//Substitute (a type of calculation)
message = "numberC is greater than 2";;
}
//Execute the instruction
System.out.println(message);
}
Recommended Posts