Java Essay (ii)

Source: Internet
Author: User

NetEase Cloud Classroom To do the Java Video after the lesson of the note, mainly about the string operation, or very rewarding. The title is: http://mooc.study.163.com/learn/ZJU-1000002014?tid=1000002010#/learn/ojhw?id=1000060003

The first question is mainly about the difference between next () and nextline (): One is to read with a space character, and one to read a line at a time. There is also the way to see the end of a string.

                NULL ;         Boolean false ;          Do {                        = in.next ();             = Word.endswith ("." );             //            System.out.print (end?) (word.length () = = 1? "": Word.length ()-1):                + "");                    }  while (!end); * *
View Code

The second problem uses more operations on strings, such as intercepting a character, converting a numeric string to an integer, and how to take the position of the trailing character when there are multiple identical characters.

String line=NULL, hhmmss=NULL;  while(! (Line=in.next ()). Equals ("END")){            if(!line.contains ("$GPRMC"))                Continue; intval = Integer.parseint (line.substring (Line.indexof ("*") +1), 16); Charn = Line.charat (1);  for(inti = 2;i<line.length () -3;i++) {n^=Line.charat (i); }                        if(n = =val) {                intFirstcomma = Line.indexof (', '); intSecondcomma = Line.indexof (', ', firstcomma+1); intThirdcomma = Line.indexof (', ', secondcomma+1); if("A". Equals (Line.substring (secondcomma+1, Thirdcomma))) {HHMMSS=line.substring (Firstcomma + 1, Secondcomma); }                if(hhmmss!=NULL)                {                    intH =0,m=0,s=0; H=integer.parseint (hhmmss.substring (0, 1)) +8; H= h>24?h-24: H; M=integer.parseint (hhmmss.substring (2,4)); S= Integer.parseint (Hhmmss.substring (4, 6)); System.out.print ((H>= 10? H: "0" + H) + ":" + (M >= 10?) M: "0" + M) + ":" +(S>= 10? S: "0" +s)); }            }        }
View Code

Java Essay (ii)

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.