본문 바로가기

Java4

[Java] Java로 배우는 자료구조 : 변수, 배열, 반복문 출처 : inflearn 클래스 이름 바꾸기 : src > class > 오른쪽 버튼 클릭 > Refactor 1. 변수 선언하기 // 클래스 밖에 변수 선언은 불가 public class Hello { // 함수 밖에 변수 선언 : static static int num; public static void main(String [] args) { // 함수 안에 변수 선언 : static 선언 안해도 됨 int anotherNum = 5; num = 2; // print out some information // 숫자 + 숫자 System.out.println(num + anotherNum); // 문자 + 숫자 System.out.println("num: " + num); System.out.prin.. 2019. 12. 16.
[JAVA] BOJ_2739 구구단 성공 시간 제한메모리 제한제출정답맞은 사람정답 비율 1 초 128 MB 78606 41611 37350 55.123% 문제 N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. 입력 첫째 줄에 N이 주어진다. N은 1보다 크거나 같고, 9보다 작거나 같다. 출력 출력형식과 같게 N*1부터 N*9까지 출력한다. 예제 입력 1 복사 2 예제 출력 1 복사 2 * 1 = 2 2 * 2 = 4 2 * 3 = 6 2 * 4 = 8 2 * 5 = 10 2 * 6 = 12 2 * 7 = 14 2 * 8 = 16 2 * 9 = 18 import java.util.*; public class BOJ_2739 { public static void main(String.. 2019. 11. 22.
[JAVA] BOJ_2741 주제 : N 찍기 문제 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다. 출력 첫째 줄부터 N번째 줄 까지 차례대로 출력한다. 예제 입력 1 복사 5 예제 출력 1 복사 1 2 3 4 5 import java.io.*; public class BOJ_2741 { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));.. 2019. 11. 22.
[JAVA] Exception Handling 1. Common Exceptions ArithmeticException: Something went wrong during an arithmetic operation; for example, division by zero. NullPointerException: You tried to access an instance variable or invoke a method on an object that is currently null. ArrayIndexOutOfBoundsException: The index you are using is either negative or greater than the last index of the array (i.e., array.length-1). FileNotFou.. 2019. 11. 20.