Java Learning Second Week summary

Source: Internet
Author: User

July 22, 2018

The second week of summer vacation is almost over, and this week I continue to learn java.

This week learned some Java modifiers, such as static, private, public, and so on, which are similar to C + + and are easy to master. Also learned to create objects and learn how to create a class's construction methods. Also learned how to use some of the basic classes in Java methods, such as the String class, StringBuffer class. There are more than 30 ways to use it in just the string class. In addition, the knowledge of code blocks, class inheritance, method rewriting is also learned.

This week's study time is estimated to reach 25 hours, from Monday to Friday on average 5 hours a day to learn new Java knowledge, Saturday Sunday Review summary. Basically, there are 1 hours of practice code every day. In addition, I also try to do the Java School test, the following is my code, there will certainly be a lot of places to optimize, and so I further mastered the Java and then to modify it.

ImportJava.util.Scanner;classStudent {PrivateString Stunumber,name; Private intAge ; Private Booleansex; Private Doublescore;  Public voidSetnumber (String a) {Stunumber=A; }     Public voidSetName (String a) {name=A; }     Public voidSetage (inta) { age=A; }     Public voidSetsex (Booleana) {sex=A; }     Public voidSetScore (Doublea) {score=A; }     PublicString GetNumber () {returnStunumber; }     PublicString GetName () {returnname; }     Public intGetage () {returnAge ; }     Public BooleanGetsex () {returnsex; }     Public DoubleGetscore () {returnscore; } Student () {Stunumber= "2017****"; Name= "King * *"; Age=20; Sex=false; Score=100; } Student (String a,string B,intCBooleanDDoublee) {stunumber=A; Name=b; Age=C; Sex=D; Score=e; }}classStudentmanager {intT=1; Student[] s=NewStudent[50]; Studentmanager () {s[0] =NewStudent ();  for(inti=1;i<50;i++) S[i]=NewStudent ("null", "null", 0,false, 0.0); }//Traverse output Student Information     Public voidshowstudent () { for(inti = 0;i<50 && s[i].getnumber (). CompareTo ("null")!=0;i++) {System.out.println ("School Number:" +S[i].getnumber ()); System.out.println ("Name:" +s[i].getname ()); System.out.println ("Age:" +s[i].getage ()); System.out.println ("Gender:" +s[i].getsex ()); System.out.println ("Score:" + s[i].getscore () + "\ n"); }    }//Information entry for new students     Public voidAddstudent (String stunumber,string name,intAgeBooleanSexDoublescore) {         for(inti = 0;i<50 && s[i].getnumber (). CompareTo ("null")!=0;i++)            if(S[i].getnumber (). CompareTo (Stunumber) ==0) {System.out.println ("Repeat, no!\n\n\n added"); return;        } s[t].setnumber (Stunumber);        S[t].setname (name);        S[t].setage (age);        S[t].setsex (Sex);        S[t].setscore (score); T++; System.out.println ("Added successfully! \n\n\n "); }//Delete Student Information     Public voiddeletestudent (String stunumber) { for(inti = 0;i<50 && s[i].getnumber (). CompareTo ("null")!=0;i++)            if(S[i].getnumber (). CompareTo (Stunumber) ==0){                 for(intj=i;j<49 && S[j].getnumber (). CompareTo ("null")!=0;j++) {S[j].setnumber (s[j+1].getnumber ()); S[j].setname (S[j+1].getname ()); S[j].setage (S[j+1].getage ()); S[j].setsex (S[j+1].getsex ()); S[j].setscore (S[j+1].getscore ()); } s[49] =NewStudent ("null", "null", 0,false, 0.0); System.out.println ("Delete succeeded!" \n\n\n "); return; } System.out.println ("No such student, no need to delete!" \n\n\n "); }//Modify Student Information     Public voidUpdatestudent (String stunumber,string name,intAgeBooleanSexDoublescore) {         for(inti = 0;i<50 && s[i].getnumber (). CompareTo ("null")!=0;i++)            if(S[i].getnumber (). CompareTo (Stunumber) ==0) {s[i].setnumber (stunumber);                S[i].setname (name);                S[i].setage (age);                S[i].setsex (Sex);                S[i].setscore (score); System.out.println ("Modified successfully!" \n\n\n "); return; } System.out.println ("Without this student, cannot be modified!" \n\n\n "); }//Query Student Information     Public voidselectstudent (String stunumber) { for(inti = 0;i<50 && s[i].getnumber (). CompareTo ("null")!=0;i++)            if(S[i].getnumber (). CompareTo (Stunumber) ==0) {System.out.println ("School Number:" +S[i].getnumber ()); System.out.println ("Name:" +s[i].getname ()); System.out.println ("Age:" +s[i].getage ()); System.out.println ("Gender:" +s[i].getsex ()); System.out.println ("Score:" + s[i].getscore () + "\n\n\n"); return; } System.out.println ("No such student!" \n\n\n "); }} Public classStudentsystem { Public Static voidMain (string[] args) {Studentmanager St=NewStudentmanager (); Scanner SC=NewScanner (system.in); intK=0;        Boundary ();  Do{            intj =Sc.nextint (); Switch(j) { Case1:st.showstudent (); Break;  Case2: System.out.println ("Enter student number:"); String Nu=Sc.next (); System.out.println ("Enter Student's name:"); String na=Sc.next (); System.out.println ("Enter student Age:"); intAG =Sc.nextint (); System.out.println ("Enter Student Gender:"); BooleanSE =Sc.nextboolean (); System.out.println ("Enter Student results:"); DoubleSCO =sc.nextdouble (); St.addstudent (Nu,na,ag,se,sco); Break;  Case3:system.out.println ("Enter student number:"); String nu2=Sc.next (); St.deletestudent (NU2); Break;  Case4:system.out.println ("Enter student number:"); String nu1=Sc.next (); System.out.println ("Enter Student's name:"); String NA1=Sc.next (); System.out.println ("Enter student Age:"); intAG1 =Sc.nextint (); System.out.println ("Enter Student Gender:"); BooleanSE1 =Sc.nextboolean (); System.out.println ("Enter Student results:"); DoubleSco1 =sc.nextdouble (); St.updatestudent (NU1,NA1,AG1,SE1,SCO1); Break;  Case5:system.out.println ("Enter student number:"); String NU3=Sc.next (); St.selectstudent (NU3); Break; default:return; }        } while(k==0); }     Public Static voidboundary () {System.out.println ("************************************************\n"); System.out.println ("School of Information Science and technology, Shijiazhuang Railway University \ n"); System.out.println ("Student information management system V2.0 \ n"); System.out.println ("************************************************\n"); System.out.println ("1. Traverse the output of student information; \ n "); System.out.println ("2. New Student information entry; \ n "); System.out.println ("3. Delete Student information; \ n "); System.out.println ("4. Modify student information; \ n "); System.out.println ("5. Check student information; \ n "); System.out.println ("6. Exit the system; \ n "); System.out.println ("************************************************"); }}

There are few problems this week, because the code is basically followed by the video, so there is no problem. But try to do the Java School test questions encountered some problems, these problems are easy to solve, Baidu a search on OK.

Next week I will continue to watch the teaching video of Java. At the end of the three-week process, I basically mastered the basics of Java.

Java Learning Second Week summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.