A little bit every day. An array of Java--initialization and basic operation of a multidimensional array

Source: Internet
Author: User

<span style= "font-family:arial, Helvetica, Sans-serif;" > * <p>description: Demonstrates initialization and basic operation of one-dimensional arrays and multidimensional arrays </p></span>
 * <p>copyright:copyright (c) 2014</p> * <p>Filename:myArray.java</p> * @author w Wanghaitao * @version   0.1 */public class myarray{//Initialize array variable char[] cNum = {' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' 0 '}; Char[] CStr = {' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R '   , ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z '};   Int[] Imonth = {31,28,31,30,31,30,31,31,30,31,30,31}; String[] Smail = {"@", "."};/ * * *<br> Method Description: Verify e-mail *<br> input parameters: String Spara checked e-mail character *<br> return type: Boolean if the format of the check conforms to the e-mail format returns True     otherwise returns false */public void IsMail (String spara) {int i=0;     if (Spara.indexof (Smail[i]) ==-1&&spara.indexof (smail[i+1]) ==-1)//Not retrieved @ and.     {System.out.println (spara+ "The content does not conform to e-mail standards");     } else {System.out.println (spara+ "The content is e-mail standard"); }}/** *<br> Method Description: Determines whether the numeric *<br> input parameter: String Spara. The string to be judged *<br> return type: Boolean. Returns true if all are numeric types, otherwise false */public boolean isNumber (String Spara) {System.out.println (Spara);    int iplength = Spara.length ();     for (int i=0;i<iplength;i++) {char ctemp = Spara.charat (i);     Boolean btemp = false;         for (int j=0;j<cnum.length;j++) {if (Ctemp==cnum[j]) {//loop compares the current character to the contents of CNum to determine if it is a number btemp = true;       Break    }} if (!btemp) {//system.out.println (Spara);      return false;    }}//system.out.println (Spara);   return true; }/** *<br> Method Description: Determine whether all English characters *<br> input parameters: String Spara. The character to check for *<br> return type: Boolean.    True if all characters are returned, and vice versa */public boolean isstring (String Spara) {System.out.println (Spara);    int iplength = Spara.length ();     for (int i=0;i<iplength;i++) {char ctemp = Spara.charat (i);     Boolean btemp = false;         for (int j=0;j<cstr.length;j++) {if (Ctemp==cstr[j]) {btemp = true;       Break     }} if (!btemp) return false;       } return true; }/** *<br> Method Description: Determine if a leap year *<br> input parameterNumber: int Ipara. The year to Judge *<br> return type: Boolean.   Returns true if a leap year returns false */public boolean chickday (int Ipara) {return ipara%100==0&&ipara%4==0; }/** *<br> Method Description: Check that the date format is correct *<br> input parameter: String Spara. The date character to check for the *<br> return type: Int.   0 Days date format is correct,-January or this day is not required,-2 month day format incorrect */public int chickdata (String Spara) {System.out.println (Spara);   Boolean btemp = false;   The input date length is incorrect if (Spara.length ()!=10) return-2;   Gets the year String syear = spara.substring (0,4);   Gets the month String smonth = spara.substring (5,7);   Gets the day String sday = spara.substring (8,10);   Converts the year, month, and day to the number int iyear = Integer.parseint (syear);   int iMon = Integer.parseint (smonth);   int iday = Integer.parseint (Sday);   if (imon>12) return-1;   Leap year February processes if (Imon==2&&chickday (iyear)) {if (iday>29) return 2;   }else{if (iday>imonth[imon-1]) return-1;   } return 0; }/** *<br> Method Description: Main method, test with *<br> input parameter: *<br> return type: */public static void Main (string[] arges) {MyArrayMA = new MyArray ();       Verify the email address ma.ismail ("[email protected]");     Ma.ismail ("tom163com");     Shows if the number is Boolean bisnum = Ma.isnumber ("1234");     System.out.println ("1:bisnum=" +bisnum);     Bisnum = Ma.isnumber ("123r4");     System.out.println ("2:bisnum=" +bisnum);     Shows if the English character is Boolean bisstr = ma.isstring ("Wer");     System.out.println ("1:bisstr=" +bisstr);     Bisstr = ma.isstring ("Wer3");     System.out.println ("2:bisstr=" +bisstr);     System.out.println ("0 days, the format is correct,-January or this day is not required,-2 year date format is incorrect");     Demo check date int iistime = Ma.chickdata ("2003-12-98");     System.out.println ("1:iistime=" +iistime);     Iistime = Ma.chickdata ("2003-111-08");     System.out.println ("2:iistime=" +iistime);     Iistime = Ma.chickdata ("2003-10-08");     System.out.println ("3:iistime=" +iistime);     Iistime = Ma.chickdata ("2000-02-30");   System.out.println ("4:iistime=" +iistime); } }


A little bit every day. An array of Java--initialization and basic operation of a multidimensional array

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.