본문 바로가기

DB엔지니어가 공부하는 python

자바를... 시작해봅니다. 자바 초보자가 자바 고인물이 되기위한 첫 발걸음



뻔하디 뻔한... java 설치 및 이클립스 설치 과정은 그냥 패스..


Head first JAVA 책 한권과..


자바 11년차 초고수 강사를 옆에 두고...


시작해 봅니다.


오늘부터 이 책에 있는 모든 코드를 해볼 예정


하나씩 올려 봅니다.



==========================

아래 코드는 난수를 발생시켜서 String 배열 안에 있는 단어중 하나씩 random 하게 가져와서


println 해주는 코드 입니다.


재미지네요..


실행해보시고 혹시 궁금한게 있으시면 답글 달아주시면 이 난이도 안에선 설명 해드릴수 있습니다.


감사합니다.


package hello_world;


public class PhraseOMatic {

public static void main (String[] args) {

String[] wordListOne = {"24/7", "multi-Tier","30,000 foot","B-to-B"};

String[] wordListTwo = {"empowered","sticky","oriented"};

String[] wordListThree = {"solution","portal","space"};

int oneLength = wordListOne.length;

int twoLength = wordListTwo.length;

int threeLength = wordListThree.length;

int rand1 = (int) (Math.random() * oneLength);

int rand2 = (int) (Math.random() * twoLength);

int rand3 = (int) (Math.random() * threeLength);

String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];

System.out.println("What we need is a " + phrase);


} //main 클래스 끝

} //클래스 끝