티스토리 뷰
Main method
the main method is the first method when we learn Java to print "Hello World". It's the entry point of Java program. The syntax is fixed and can't be changed. Only the name of the String. for instance, you can change args below.
public static void main(String[] args)
public
Java runtime 이 이 메소드를 실행 할 수 있도록 public 으로 설정
static
인스턴스화 하지 않아도 static메서드는 호출가능
void
main method 는 return type이 없기 때문에 void
main
main method 의 이름
String[] args
Java main method는 String array 타입의 argument 하나만 허용(=java command line arguments)
args is a changeable name.
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
double d = scan.nextDouble();
scan.nextLine();
String s = scan.nextLine();
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
Reference
Hackerrank (https://www.hackerrank.com/)
w3schools (www.w3schools.com)
'JAVA' 카테고리의 다른 글
Nested if-else example (0) | 2019.01.02 |
---|---|
instance in Java (0) | 2018.12.31 |
Java Data type (primitive & non-primitive) (0) | 2018.12.18 |
Java loop example (0) | 2018.12.18 |
Scanner class in Java(User input) (0) | 2018.12.18 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- repeat()
- hackerrank javascript solution
- easy javascript algorithm
- HackerRank Algorithm
- javascript
- 프로그래머스 알고리즘
- rest parameter
- 프로그래머스
- hackerrank javascript
- Javascript Algorithm
- code refactoring
- substring()
- HashMap
- Collection Framework
- equals()
- 프로그래머스 알고리즘문제
- string class in java
- ... in Javascript
- C++
- Object type casting
- java
- math.abs
- compareTo()
- hackerrank solution
- easy algorithm
- math.max
- hackerrank
- 알고리즘
- spring boot application
- algorithm
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함