??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????xxx.pareseXxx????(??Integer.parseInt("12"))??
public class AutoConversion {
public static void main(String[] args) {
int a = 6;
float f = a;
System.out.println(f);//6.0
byte b = 9;
//char c = b;//?????byte???????????char
double d = b;
System.out.println(d);//9.0
//??????????????????????
String s = 5.3F + "";
System.out.println(s);//5.3
System.out.println(3 + 4 + "Hello!");//7Hello!
System.out.println("Hello!" + 3 + 4);//Hello!34
}
}
?????????????????????????????????????????????????????????????????????????????????????????????????????????С???
????public class ForceConversion {
????public static void main(String[] args) {
????int i = 234;
????byte b = (byte)i;
????System.out.println(b);//-22
????double d = 3.56;
????int n = (int)d;
????System.out.println(n);//3
????}
????}
?????????????234?????byte?????-22???????????????byte???Χ??-128~127????????????????Χ??234??????????00..0011101010???????????8λ?????11101010???????λ?????λ(???????????)???????????????????????????????????????(?????1????????λ?????????λ????????11101010-->11101001-->10010110)??
????????б????????????????????????????????????byte??short??char??????????int????????????????????????????????????????????????????????????????????????????С???????????????????????????????????????????????????????ж???????????????????????
????public class AutoPremotion {
????public static void main(String[] args) {
????short s = 5;
????//s = s - 2;//????????????????int
????byte b = 10;
????char c = 'a';
????double d = .12;
????System.out.println(b + c + d);//???????????double
????System.out.println(23 / 3);//7
????System.out.println(b + c + "Hello!");//107Hello!
????System.out.println("Hello!" + b + c);//Hello!10a
????}
????}
???????????????????????????????????????????????????????????3???
????public class CompareString {
????public static void main(String[] args) {
????String a = new String("Miracle");
????String b = new String("Miracle");
????System.out.println(a == b);//false?????a??b?????????(???????????)
????String c = "Miracle";
????String d = "Miracle";
????System.out.println(c == d);//true????????????????????????????????????????
????}
????}
?????????????·?????(??||)????·?????(??|)??????: ||????????????????????true???????????????|???????????ζ?????????????????
????public class TestLogicOperator {
????public static void main(String[] args) {
????int a = 5;
????int b = 10;
????if(a > 4 || b++ > 10)
????{
????System.out.println("a=" + a + "??b=" + b);//a=5??b=10
????}
????if(a > 4 | b++ > 10)
????{
????System.out.println("a=" + a + "??b=" + b);//a=5??b=11
????}
????}
????}
????????????????????????????κα??????(Java???????)??????????????????????????(if??if...else??if...else if...else??switch)???????(while??do...while??for??foreach)?????????????????????????????????if...else??????????????????????????????????????????????ж?????????if...else??????????????????(if(a>b)?a:b)????????????????????????????????????????????ΧС?????????????洦???
????public class TestIf {
????public static void main(String[] args) {
????int age = 45;
????if(age > 20) {
????System.out.println("Young");
????} else if(age > 40) {
????System.out.println("Middle");
????} else if(age > 60) {
????System.out.println("Old");
????}
????}
????}
?????????????????????Young??????????????(??????Middle)???????????????Χ??????(age > 20??age > 60??Χ??)???????д??£?
????public class TestIf {
????public static void main(String[] args) {
????int age = 45;
????if(age > 60) {
????System.out.println("Old");
????} else if(age > 40) {
????System.out.println("Middle");
????} else if(age > 20) {
????System.out.println("Young");
????}
????}
????}
?????????if????????????????????switch...case?????case??????????????????break??????(?????????case???)??????????default?????????switch(expression)?????????????????????????(????????????????)??
????????????????????????????е??????(?????????)????????????????????????????break??????????????????????????????continue???????????????????????????????????return????????????????????????????????????????????????????????Java???(??:???)?????????????????λ??break????????????????????????á????3??????: i = 0??j = 0;i = 0??j = 1??
????public class TestBreak {
????public static void main(String[] args) {
????outer:
????for(int i = 0; i < 5; i++) {
????for(int j = 0; j < 2; j++) {
????System.out.println("i = " + i + "??j = " + j);
????if(j == 1) {
????break outer;
????}
????}
????}
????}
????}
????????continue?????????????????????continue????????????????????λ?y???????????????????????break???continue??????????: i = 0?? j = 0; i = 0?? j = 1; i = 1?? j = 0; i = 1?? j = 1; i = 2?? j = 0; i = 2?? j = 1; i = 3?? j = 0; i = 3?? j = 1; i = 4?? j = 0; i = 4?? j = 1????return???????????????????????????????ж?????????