JAVA ?????????
???????????? ???????[ 2014/2/20 9:19:58 ] ????????JAVA ?????? ???й?
????c) ??????????????????
???????????????new??????????????????????????????Щ?????????????б?????????????????????????????????????????????????????磺
????Rectangle r1= new Rectangle(3??5);
????Rectangle r2= new Rectangle(4??6);
??????????????????з??????????????????width??height??????????????????????????????????????????????У?
????Rectangle r1= new Rectangle(3??5);
????Rectangle r2=r1;
????????????????????????????????????????д???????????????????????????????????????????????
????d) ?????
????????????ж??????????int???Integer??double???Double???????????????嶼?????????У?????e????????????????????????????????磺int i=0??i???洢????С? Integer i??i???????? = new Integer(5)????????i????????洢????У?i??????洢????У??????е???????????????
????e) String
????String???????????????????????????????????????????String str = new String("abc")??String str = "abc";
????????????????????????????????????????
?????????????????Java????????????????????????裺
????(1) ???????????str???String???????????????String str??
????(2) ????в???????д????"abc"???????????У?????????????????"abc"
????????????????????μ?String??????o??????o??????????????????????????
???????????????????????????o??????????????"abc"??????????????o????
??????o??????
????(3) ??str??????o??????
?????????????????String??????????????????????????String str = "abc"??????
???????£?????????????????????????????????????á?
??????????????????????????????????μ????????????????
????String str1="abc"??
????String str2="abc"??
????System.out.println(s1==s2)??//true
???????????????str1.equals(str2)???????????????????????????????????==???????JDK?????????????????????????????????????????????????????????????????str1??str2????????????????
?????????????????μ????
????String str1= new String("abc")??
????String str2="abc"??
????System.out.println(str1==str2)??//false
?????????????????á??????????????????????÷????????????????
???????????δ??????????????new()???????????????????д??????????????????????????????????е???????????????????е?????????
????f) ????
????????????????飬int x[]????int []x????????????д????????????????????????????????????????????顣x=new int[3]???????????з???3??????int???????????????????????????У??????????????????0??
????g) ???????
??????static?????ε?????????????????????????Щ???????????????е?"???λ??"??static storage??????????????????????е??????static?????е???????C?е?????????????????????????????????????????????????????????????static???????????JVM???????????????????????????????????????λ???????????????????????????????????????????????????????????? ?????????????????????????????????????????????????static??????instance??????????????????????instance???????????????????????static????????????????????????????????????????????????????????????ν??г?????? ?????????????????μ?????????????????
class Student{
static int numberOfStudents=0;
Student()
{
numberOfStudents++;
}
}
???????δ???????μ?Student?????????numberOfStudents???????????????????е?Student?????????????numberOfStudents???????????int numberOfStudents?????????????洢?????λ?????
????5. Java???????????
????Java???????????(????????????????)??????????????????λ????????????????????????3???????????????????????????
????????????????????????
???????????????????
??????????????java???????????????????δ???????????????У?
????public class Dog {
????Collar c;
????String name;
????//1. main()????λ?????
????public static void main(String[] args) {
????//2. ???????????????d????Dog??????δ????
????Dog d;
????//3. ?????μ?Dog?????????丳??d???????
????d = new Dog();
????//4. ???????????????????????go()????
????d.go(d);
????}
????//5. ??go()????????????????dog??????????????
????void go(Dog dog){
????//6. ?????????μ?Collar?????????丳??Dog?????????
????c =new Collar();
????}
????//7.??setName()????????????dogName???????????????
????void setName(String dogName){
????//8. name??????????????String????
????name=dogName;
????}
????//9. ???????????setName()??????????????????????????????dogName?????????????????????String???????
????}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11