소 백 학 자바
1. 자바 환경 설정 2, 자바 코드 규범 3, 자바 노트 4, 자바 프로그램 작성
자바 환경 설정
1. 자바 다운로드 에 필요 한 JDK (내 가 다운로드 할 때 1.8 버 전) 주소: 주소 JDK 2, 다운로드 IDEA 주소: IDEA 주소 3, 등록 서버 작성http://idea.iteblog.com/key.php
자바 코드 규범
1、java ,
2、java
(1) 、 、 、$ 、 ( 、 )
(2)
(3) java goto
(4) java System
(5) ,
3、 '
자바 노트
:
: , , , ,
:1、 2、 3、
: 1: / : {} ( )2: :
:1、 ( )2、 ( , } )
:1、 , 2、 , 3、 4、
: oc , = boolean ? 1: 2( :boolean ture, 1, false 2)
(method) (function) :
JAVA :1、
: static , , “.” , new 2、java main jvm(java ) , jvm , main 。
java :[ ] ([ 1, 2]){
:
[ , return ];
}
:
:public,static , , static
: , , , , void , 。
: , , , , 。
: , , , 。
: == + +
: == + (eg:doWork(int a,int b)) 。
: {} ,
:1、 return 2、 : , void 3、 :
,
: ,
:
?
?
: , , void , , 。
eg: , , ,
?
: , , , 。
eg: , , ,
:1、 : , , 2、 。3、 :“” ( : , : )⚠️: , .
:getSum(1,2); /* */getSum(1.2,1.1);/* double*/ ( , , )
JVM ,
: .
: native
java : java , , , , ⚠️: , ( ) , 。
java : , , ( new , )
: , , , ( )
: , , 0x******
: ,new , 16 0x********, , , 。
GC(Garbage Collection): :
java : , jvm , ( ) .⚠️ java , , , 。
:
: , , , 。 , , 0 , 1, excel , ,
:byte short int long float double char boolean
:
:
1: [] ; int[] ages;
2: [];int ages[];
⚠️: , 4
:
: ,
: [] = new [] { 1, 2, 3,........};
int[] num = new int []{1,3,5,7,9};
( , ):int [] num = {1,3,5,7,9};
int [] num = new int[]{1,3,4,5}; (1、 int 2、 3、 num )
System.out.println(num.length);
num = new int[]{2,4,8};
System.out.println(num.length);
: , 1345, num 1345, new , 248 , num , num , num 248,
:
( ) .
: [] = new [length];
eg.:int [ ] args = new int [100];
/* */
int [] num = new int[3];
System.out.println(num.length);
num = new int[5];
System.out.println(num.length);
: , 。 num 。 num ( 3 5)
, ?
: , 。
⚠️: , , , ,
⚠️:
:
1、 : = [index];
2、 : [index] = ;
3、 : for
4、 : .length;length ,
5、 : 0 , ,[0, .length-1];
:
/*final */
final int bill = 100;
/* */
0 0X
, , ( :float long float , float )
double float float 1.0 F, 1.0F。
:/* long */
/* */
int d = (int)Math.round(-10.9);
System.out.println(d);
:
' ' “ ”
: \"\"
System.out.println(" \"5 7\"");
&& ||:
&& true true || false false
: !> && > ||
: while do while do while while
int type = 1;
do {
type ++ ;
}while (type>3);
System.out.println(type);
break continue :
break continue 。 break . ? , break 。 for 。 break ; OK 。
:
:
:(int)(Math.random()*100)
int [] hour = new int[(int)(Math.random()*100)];
System.out.println(hour.length);
for(int i =0 ;i
자바 방법 호출
public class Main { public static void main(String[] args) { System.out.println("Hello World!"); Main.doWork(); } static void doWork(){ System.out.println(" ");// } public static void work(){ System.out.println(" "); }}
자바 프로그램 작성
public class Main { public static void main(String[] args) { System.out.println(" "); }}
삼원 식
public class Main { public static void main(String[] args) { double num = 3.51; int num1 = (int)num; double num2 = num - num1; int result = num2>= 0.5 ? num1+1 :num1; System.out.println(result); }}
java 매개 변수 없 음 반환 값 없 음 매개 변수 없 음 반환 값 있 음 매개 변수 없 음 반환 값 있 음 demo 있 음
public class Main { public static void main(String[] args) { System.out.println("Hello World!"); Main.doWork(); Main.p();/* */ Main.pValue("hello");// int age = Main.getAge(); System.out.println(age); int sum = Main.getSum(3,4); System.out.println(sum); } /* */ /* : ---------*/ static void p(){ System.out.println("---------");// } /* */ /* : */ static void pValue(String va){ System.out.println(va);// string } /* */ /* : */ static int getAge(){ return 17; } /* */ /* */ static int getSum(int a,int b){ return a+b; } static void doWork(){ System.out.println(" ");// } public static void work(){ System.out.println(" "); }}
자바 문자 보 내기 기능 구현 (참조)
public class Main { public static void main(String[] args) { System.out.println("Hello World!"); int ret = sendMsg("10086"," "); int temp = sendMsg("10010"," "); } /* */ // sendMsg /*0: 1: 2: * */ static int sendMsg(String phoneNum, String content){ /* */ return int ; }}
자바 로그 인 기능 구현
/* */static boolean login (String username,String password){ /* */ /* bool */ }
자바 재 귀 알고리즘 구현
, , , :F(0)=0,F(1)=1,Fn = F(n-1)+F(n-2), F(5) , ?
public class Main { public static void main(String[] args) { System.out.println("Hello World!"); int ret = fn(6); System.out.println(ret); } static int fn (int n){ if (n==0){ return 0; } else if(n==1){ return 1; }else { return fn(n-1)+fn(n-2); } }}
sout
psvm
자바 프로그램 에서 자주 발생 하 는 오류 메시지 (콘 솔)
java.lang.NullPointerException---- ( )
ArrayIndexOutOfBoundsException------ ( , )
문자열 맞 춤 법
Scanner in = new Scanner(System.in);
/*in.nextLine in nextLine () . + , 。 */
// System.out.println(in.nextLine());
/* */
System.out.println("Answer:"+in.nextLine());
간단 한 감법 연산
public class Hello {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
/* */
int price = 0;
/* = */
/* */
price = in.nextInt();
int chage = 100-price;
System.out.println(chage);
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.