Android_ a custom toggle control SwitchView

Source: Internet
Author: User

Today did a teacher to give the first set of questions, the first question is to determine whether a string in another string: Do a bit, feel a good variety of writing, Java class really much ah, to master some of the basic class usage:

Package Com.exam.e120;public class Java1 {public static void main (String[]args) {String str1,str2;str1= ' I am Tom, I am from China. "; Str2= "Tom"; int i=str1.indexof (STR2);//The first method//if (Str1.contains (STR2))//The second method if (i!=-1) System.out.println ("\" "+ str2+ "\" is in the String:\ "" +str1+ "\" ") elseSystem.out.println (" \ "" +str2+ "\" was not in the String:\ "" +str1+ "\" ");}

This is just some of the most basic and simple questions, we can also accumulate some basic classes of usage from these problems, learning lies in the accumulation!

Here we use the string this class, can use inside of indexof this method, also can use contains this method;

IndexOf This method returns the position of the first occurrence of a string in another string (or possibly a character), and the output-1 (position starting from 0) is not found.

Contains this method to call it directly, see if the string contains another string (as if there are many classes inside this method, later encountered in the study).

The second problem is to print out the names of all the fonts in the current system; The problem is to call the method directly inside the class; Graphicsenvironment.getlocalgraphicsenvironment (). Getavailablefontfamilynames ();

Package Com.exam.e120;import Java.awt.graphicsenvironment;public class Java2 {public static void main (string[] args) { string[] FontNames = Graphicsenvironment.getlocalgraphicsenvironment (). Getavailablefontfamilynames (); for (int i = 0; i < Fontnames.length; i++) System.out.println (Fontnames[i]);}}
When we use a class that we haven't seen, it's a good practice to check the API documentation, and here we look at the API documentation.


API documentation is an official introduction, after watching we basically know how to use the class and method ~


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.