how to practice coding in java

Read about how to practice coding in java, The latest news, videos, and discussion topics about how to practice coding in java from alibabacloud.com

Java Exception Practice

"); /* No abnormalities, the teacher's normal class * *}}Class Lanpingexception extends Exception/* Custom blue screen Exception */{Lanpingexception (String m){Super (M);}}Class Maoyanexception extends Exception/* Custom Computer Smoke Exception */{Maoyanexception (String m){Super (M);}}Class Noplanexception extends Exception/* Custom teacher Handling Exception */{Noplanexception (String m){Super (M);}}Class computer{private int state=3; /* Different exception State selection */public void Run (

Java Practice-Scrolling text

  Java Practice-Scrolling text

Learn to practice Java Object-oriented trapezoid area

1 PackageCom.hanqi;2 3 Public classLadder {4 5 DoubleShangdi;6 DoubleXiadi;7 DoubleGao;8 DoubleMianji;9 TenLadder (DoubleShangdi,DoubleXiadi,DoubleGao) One { A //using parameters to initialize properties - //This represents the current class - This. Shangdi =Shangdi; the This. Xiadi =Xiadi; - This. Gao =Gao; - - } + //method naming: verb + name; verb First letter lowercase - //void means no return value +

Learn to Practice Java writing a journey to the character class

1 PackageCom.hanqi;2 3 Public classXiyoujirenwu {4 5 Doubleheight;6 7 String weapon;8 9 String name;Ten One voidPrinetname () A { - System.out.println (name); - } the - voidPrinetweapon () - { -System.out.println ("Weapon" +weapon); + } - + Public Static voidMain (string[] args) A { atXiyoujirenwu SW =NewXiyoujirenwu (); -Sw.name= ("Monkey King")); -Sw.weapon= ("Ruyi Golden Cudgel"); -System.out.println (sw.name+ "using" +sw.weapon);

Learn to practice Java Object-oriented deposit and withdrawal enquiry balance

1 PackageCom.hanqi;2 3 Public classAccount {4 5 String Zhanghao;6 7 DoubleCunkuanyue;8 9Account (String Zhanghao,DoubleCunkuanyue)Ten { One //Initialize A This. Zhanghao =Zhanghao; - This. Cunkuanyue =Cunkuanyue; - } the - //Deposit - //a method with no return value with parameters - voidCunkuan (DoubleQianshu) + { -System.out.println ("Saved" +Qianshu); + This. Cunkuanyue + =Qianshu; A } at - //Withdrawal

Java Exception Practice

Doublebalance; PublicBank (Doublebalance) { Super(); This. Balance =balance; } Public DoubleGetBalance () {returnbalance; } Public voidSetbalance (Doublebalance) { This. Balance =balance; } DoubleWithDrawal (DoubleDamount)throwsException {if(damount>balance) { Throw Newinsufficientfundsexception (); } if(damount) { Throw Newnagativefundsexception (); } return This. Balance; } Public Static voidMain (string[] args) {Bank

Java Cycle Practice: The problem of hundred chickens

chickens: 78 Cocks: 13 only Hens: 4 only chicks: 69 Cocks: 13 Hens: 5 Chick: 60 cocks: 13 Hens: 6 Chicks:51 Cocks: 13 Hens: 7 Chickens: 42 Cocks: 13 Hens: 8 only chickens: 33 Cocks: 13 only Hens: 9 only chicks: 24 Cocks: 13 Only Hens: 10 Chick: 15 Cocks: 13 Only hens: 11 Chicks: 6 Cocks: 14 only hens: 1 Chicks: 81 Cocks: 14 only hens: 2 Chicks: 72 Cocks: 14 Hen: 3 chickens: 63 Cocks: 14 only hens: 4 Chickens: 54 Cocks: 14 Only hens: 5 Chicks: 45 Cocks: 14 Hens: 6 Ch

Java Basic Knowledge Network programming (TCP practice)

)). Start (); } }} class userloginthread implements Runnable{ PrivateSocket s; Userloginthread (Socket s) { This. s=s; } Public voidRun () {Try{BufferedReader burin=NewBufferedReader (NewInputStreamReader (S.getinputstream ())); for(intI=0;i3; i++) {String user=burin.readline (); System.out.println ("username sent to:"+user);if(user==NULL) {System.out.println ("is empty"+user); Break; } BufferedReader bur=NewBufferedReader (NewFileReader ("User.txt")); String line=NULL;Booleanflag=false; w

Java Basic Practice Writing 2 interfaces

Write 2 interfaces:interfacea and interfaceb; in interface interfacea There is a method void in the Printcapitalletter (); there is a method in interface interfaceb void printlowercaseletter () ; thenWrite a class print Implementation interface Interfacea and interfaceb, require print Capitalletter () methodImplements the output uppercase English alphabet function, theprintlowercaseletter () method implements the output lowercase EnglishThe function of the alphabet. Write a main class e, creat

Java practice of 04JavaWeb-03 session technology, java04javaweb-03

Java practice of 04JavaWeb-03 session technology, java04javaweb-03I. Introduction to session Technology 1. What is session? Why is session technology required? Session: the process from opening a browser, accessing a website, to closing the browser is called a session. The http protocol is in the status.2. Classification of session Technology Client Storage Technology: Cookie Server storage technology: Sess

The second season of Java, chapter fifth, stage practice

/***┏┓┏┓*┏┛┻━━━┛┻┓*┃┃*┃━┃*┃> */ Public classTest { Public Static voidMain (string[] args) {person P1=NewChinese (); Person P2=NewAmerican (); P1.say (); P2.say (); }}/*Output: Hi Hello*/ Public Abstract class Person { abstractvoid Say ();} Public class extends Person { publicvoid say () { System.out.println ("Hello");} } Public class extends Person { publicvoid say () { System.out.println ("Hello");} }A sayable interface can also be implemented.The seco

Basic practice of XML and DTD for Java EE

auto-generated method stub//Check Find XML, first create Documentbuilderfactory instance documentbuilderfactory factory = Documentbuilderfactory.newinstance ();// Create an Documentbuilder instance by documentbuilderfactory instance Documentbuilder Builder = Factory.newdocumentbuilder ();// The parse method is called through the instance of Documentbuilder to read the XML file document doc = Builder.parse ("Src/loclist.xml"); test04 (DOC);} 1. Traverse all nodes public static void tes

multithreaded Practice (Java)

] =mid; + } A } at } - for(inti=0; i) - { - System.out.println (Thread1[i]); - } -System.out.println ("Thread1 printing completed. "); in } -}1 Importjava.util.Arrays; 2 3 Public classThread2ImplementsRunnable {4 5 Private intthread2[]; 6 Thread2 (randomnumber rn)7 { 8 //Thread2 = new Int[rn.num.length]; 9Thread2 =Rn.num; Ten } One A Public voidRun () - { - Arrays.sort (Thread

Java Basics Enhanced IO flow Note 50:io Stream practice copy multi-level folder cases

);Wuyi } the } - Private Static voidCopyFile (file srcfile, file newFile)throwsIOException { WuBufferedinputstream bis =NewBufferedinputstream (NewFileInputStream ( - srcfile)); AboutBufferedoutputstream BOS =NewBufferedoutputstream ( $ NewFileOutputStream (NewFile)); - byte[] Bys =New byte[1024]; - intLen = 0; - while(len = Bis.read (bys))! =-1) { ABos.write (bys, 0, Len); + } the bos.close (); - bis.close (); $ } the}

Java Reflection Mechanism Demo practice

Recently in the study of the Java reflection mechanism, watching online video, and copied down the study, using the Servlet annotations, no less than the use of SPRINGMVC annotations, hereby record sharing, Servlet no longer need to pass parameters to determine the worry, focus on the business!1. First define a parent class, all of which are inherited by all business operations.1 PackageController;2 3 Importjava.io.IOException;4 ImportJava.lang.refle

Java Annotations and reflections the practice of making DAO base classes

(). Getannotation (Table.Class); sql+=Tab.name () +"Set";Get Table name StringWH ="";Record Field name String k=""; Boolean bl=false;Record whether the primary key is emptyfor (FieldFl:fiels) {Cyclic assemblyFl.setaccessible (TRUE);Turn on access to a private variable Object tobj=Fl.Get (obj);if (tobj!=null) {IfFl.isannotationpresent (Key.Class)) {Determine if there is a primary key bl=true; k=Fl.getname () +"= '" +tobj.ToString () +"' Where";}else{if (!Fl.isannotationpresent (Notrecord.Class))

Java If statement practice

();System.out.println ("please Enter your weight");Scanner sc3=new Scanner (system.in);String B=sc3.nextline ();Double gao=double.parsedouble (a), zhong=double.parsedouble (b), bz=gao-100;If (bz-zhong>=-3 bz-zhongSystem.out.println ("you are the standard weight");}else if (bz-zhongSystem.out.println ("you are overweight");}else{System.out.println ("you are thin");}}else if (sex.equals ("female")){System.out.println ("please Enter your height");Scanner sc2=new Scanner (system.in);String A=sc2.n

Algorithm note _079: Blue Bridge cup practice interval k large number query (Java)

) { inti = 0, J = 0; while(i Rightarray.length) {if(leftarray[i] >=rightarray[j]) Array[start+ +] = leftarray[i++]; ElseArray[start+ +] = rightarray[j++]; } while(i ]; while(j ]; } public voidPrintresult (int[] array,int[] [] Query) { int[] result =New int[query.length]; for(inti = 0;i ) { int[] Temparray =New int[array.length];//this gets the cloned object of the array, requiring the address to be Changed. If you assign a value directly, the two addre

Section III Java Array (loop through, get the maximum value of the array (max and min), select Sort, bubble sort, practice console output uppercase a)

>a;i--) {//Outputs 5 spaces for a loop, reducing this to 1;Systen.out.print (""); The loop output space is not bhakta;} Systen.out.println ("*"); The first line ends with a newline so use println;} else{for (int i = 5;i>a;i--) {//Outputs 5 spaces for a loop, reducing this to 1;Systen.out.print (""); The loop output space is not bhakta;Systen.out.println ("*"); Then the output space, plus *;if (a==5/2+5%2) {//is taken to the middle value;for (int b =1;bSysten.out.print (""); The loop output space

Classic Graph algorithm Java code Practice: Bfs,dfs and several shortest path algorithms

("findpathbydfs:a to K"); M.findpathbydfs (A,K); System.out.println (); System.out.println ("Findpathbybfs:a to K "); M.FINDPATHBYBFS (A,K); System.out.println (); System.out.println ("Bellmanford from A:"); M.bellmanford (a); System.out.println (); System.out.println ("Dijkstra from A:"); M.dijkstra (a); System.out.println (); System.out.println ("bellmanford,print example from A:"); M.floydwarshall (); M.printfloydwarshallforonecity (a);}}Import Java.util.arraylist;import Java.util.linkedlist

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

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.