Although previously done a more complex variety of data structure, but that is only after reading C++prime7 chapter, do not take into account the class copy reflects the class value or class pointer, so write some semi-finished class, but those
Package Test;import java.util.scanner;//Demo User Login program//idea://1. Receive username and password with two string classes//2. Determine whether the user name and password entered are consistent; consistent input success , otherwise re-enter//3
= = In eight primitive data types, determine whether the values on both sides are equal. For an object type, the memory address is determined, so the condition for true is that both sides of the reference point to the same object.such as String S1 =
1.Length--Take string lengthstring x = Console.ReadLine ();int i = x.length;Console.WriteLine (i);Execution Result:2.Substring (from which one to start, intercept a few)--intercepts the string and intercepts 3 bits from the sixth position, including
The class and methods used:1. Class StringString s;S.charat (i);2. Class Character: http://docs.oracle.com/javase/7/docs/api/java/lang/Character.htmlisLetterOrDigit(char ch)Determines if the specified character is a letter or digit. Return Static
Length (): Gets the string length the space is also the length of his
Get the implementation of the length of a string:zichuan.length ()
CharAt (): Gets the character at the specified position
Implementation method:Zichuan.charat ()
#include using namespace std;//deep copy://class string//{//public:////default construction//string ( Char *string= "")//:_str (New char[strlen (String) +1])//{//strcpy (_str, string);//}//// If the copy constructor or assignment constructor is not
Example: string example = "Hello,world";1. Property of String: Length: The user gets the lengths of the string: many times the function is to determine whether the length of the string is zero to determine whether a known object existsResponse.Write
String S1;How to use the length function: S1.length ();How to use the CharAt function: S1.charat (int Index) to get the character at the specified position//How to use the GetChars function: s1.getchars (int srcbegin,intsrcend,char[]dst,int dstbegin)
The most commonly used is the length () function, which is to find the lengths of the stringsString s= "";int I=s.length ();I result is 0.If it is a string s=null;int I=s.length ();Compile right. Operation will be errorCharAt () function:The charAt (
//define an empty string, string stra = string. Empty; Stra = "ABCDESABCSKKKKK"; Gets the length of the string int i = Stra.length; The letters are converted to lowercase stra = stra.tolower ();
---restore content starts---. ToLower ()Convert to lowercase string "abc"--"ABC". ToUpper ()//to uppercase "ABC"--"ABC". Trim ()//Remove the space "ABC" and "ABC" of the string. Equals (string Value,stringcomparison comparisonType); Equal
The Equals () method, which is defined in the object class, so that every class in Java has that method, and for the Equals () method of the object class, it is the same as the reference that invokes the Equals () method. That is, whether these two
1. Length (): View string length2, CharAt (): Gets a value in a string3. GetBytes (): Converts a string to a byte array4. ToCharArray (): Converts a string to a character array5, CompareTo (): Compare the size of two strings, return 0 for equality,
String.IndexOfString.IndexOf method (Char, Int32, Int32)Reports the index of the first occurrence of a specified character in this instance. The search starts at the specified character position and checks the specified number of character positions.
package com.ckw.mianshi;/** * Test The Intern method of the String class * @author Administrator *intern () : Returns a string with the same contents as this string, but it is guaranteed to come from a string pool. */public class Stringofintern
int Length (); Returns the length of a stringpublic static void Main (string[] args) {String str = "helloworld!";int x= str.length ();System.out.println (str+ "Length" +x);}char charAt (int index); Returns the character of the index+1 positionpublic
Class libraries: Methods and constants that contain a bunch of classes so that we call directly(1) Numerical class numericBase class numeric contains two subclasses integer (integer) and float (floating-point number)where integer (integer) can also
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.