Android generates random numbers

Source: Internet
Author: User

public void Getcharandnumr () {//String val = "", va= "";                 String a= "", b= "", c= "", d= "";     Random random = new random (); for (int i = 0; i < 1; i++)//{//String Charornum = random.nextint (2)% 2 = = 0? "Char": "num";        Output letter or number/if ("char"). Equalsignorecase (Charornum))//string//if (true) {int choice = random.nextint (2)% 2 = = 0? 65:97;//Get capital letters or lowercase letters//a + = (char) (CH             Oice + Random.nextint (26));               B + = (char) (Choice + random.nextint (26)); Choice = random.nextint (2)% 2 = = 0? 65:97;        Gets the uppercase or lowercase letter A + = (char) (Choice + random.nextint (26)); }//else if ("num". Equalsignorecase (Charornum))//number//if (true)//{////va  L + = string.valueof (Random.nextint (10)); int choice = random.nextint (2)% 2 = = 0? 65:97; Get uppercase or lowercase letters/a + = (chAR) (choice + random.nextint (26));   B + = (char) (Choice + random.nextint (26));   } TextView tw1= (TextView) Findviewbyid (R.ID.TEXTVIEW3);  String a= "", b= ""; c = string.valueof ((int) (Math.random () * 9+1)); D = string.valueof ((int) (Math.random () * 9+1)); Tw1.settext (A + "" +c+ "" +b+ "" +d+ ""); }//Contentvalues values = new Contentvalues ();     Values.put ("Name", Tw1.gettext (). toString ());//Db.insert ("tb_1", null, values);  }

Related Article

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.