#include This article is from the "12148490" blog, please be sure to keep this source http://12158490.blog.51cto.com/12148490/1876797The C++sting class found the same character in the string and removed it.
have multiple pointers pointing to the same piece of space, we just need to set a pointer variable so that it records the number of pointers to that space, as long as the pointer variable's content is 1, we release the space, or we let the counter minus 1. This is the main idea of copy-on-write, so let's use the copy-on-write method to implement a simple string class.method of copy on write time Copy-on-write mode class String{friend ostream operatorHere we place the position of the counter p
public static void Main (string[] args) {String S1 = new StringBuilder ("Computer"). Append ("Software"). toString ();//In the heapSystem.out.println (S1.intern () ==s1);//Intern Returns a value pointing to the heap "reference to computer software" with S1 pointing to the same piece of heap memory, same, returns TrueString d= "class";//Add "class" string constant to the constant pool in the method areaString s2 = new StringBuilder ("CLA"). Append ("ss"). ToString ();//stringbuilder is created in
variable to record the number of pointers to this space, as long as the contents of the pointer variable 1 we release the space otherwise let the counter minus 1, which is the main idea of the copy, Let's use the write-time copy method to implement a simple string class.
Methods of writing-time copying
How to copy in writing class String {friend ostream operator
Here we place the counter where the pointer points to the first four bytes of the data space
Test Cases:
void Test1
One, String class A string is a sequence of characters.1. Build a String // Directly the string literal is treated as a string object. String message = "Weclome to JAVA"; // using character arrays Char []
=============== Code ==================Package com.cratd;Import Java.util.Random;public class Mymain {/*** @param args*/public static void Main (string[] args) {TODO auto-generated Method Stubint A;Int[] B = new Int[5];int[] x = new INT[3];Int[] []
Nested class:
In C ++, you can place the class declaration in another class. A class declared in another class is called a nested class. It provides a new type Class scope to avoid name confusion.
Nested classes and access permissions:
First, the
The string object cannot be changed. Every time you use a method in the system. string class, you must create a new String object in the memory, which requires a new space for the new object. If you need to modify the string repeatedly, the system
Import java. Lang. String;Import java. RMI. RemoteException;Import java. util. iterator;Import java. util. List;
Import org. Apache. axis2.axisfault;Import org. dom4j .*;
Public class user{
// Convert an XML string into an HTML language in the form
1. Ext.Msg.alert (String title,string Msg) [Ext.MsssageBox.alert (Sting title,sting msg,fn)] and The difference between the JavaScript Standard alert () is that theformer is executed asynchronously and does not affect the execution of the subsequent program (the program segment is placed in the callback function to mimic the standard alert function), the latter is synchronous execution, Will prevent the su
Last night I dreamt of San Pedro
Just like I 'd never gone, I knew the song
A young girl with eyes like the desert
It all seems like yesterday, not far away
Chorus
Tropical the island breeze
All of nature, wild and free
This is where I long to be
La isla bonita
And when the samba played
The sun wocould set so high
Ring through my ears and sting my eyes
You Spanish lullaby
I fell in love with San PedroWarm wind carried on the sea, he called to meTe di
$ this-> redis-> zadd ($ k Ey, $ value);}/*** obtain the corresponding element of the set * @ param string $ setName set name */public function smembers ($ setName) {return $ this-> redis-> smembers ($ setName);}/*** build a list (similar to stack) * @ param sting $ key KEY name * @ param string $ value */public function lpush ($ key, $ value) {echo "$ key-$ value \ n "; return $ this-> redis-> LPUSH ($ key, $ value);}/*** build a list (first, simila
. Is there any way for the database to convert this field? (my database knowledge is poor )?
You are the best expert.
The following is my code using the eval function.
PHP code
$a = array("12.1","10","sting");foreach ($a as $t){ eval("\$t = $t;"); var_dump($t); echo '';}
------ Solution --------------------
I am also a beginner. based on what I just learned, I tried to compile a code segment to see if it is what you want:
$ A = a
'---------------------------------------------------------------------'; ?>
String strtolower (string subject) // Convert to lowercase
String strtoupper (string subject) // Convert to uppercase
String ucfirst (string subject) // uppercase letters
String ucwords (string subject) // uppercase letters of each word
String ltrim (string subject) // remove left blank
String rtrim (string subject) // remove the right blank
String trim (string subject) removes the left and right white spaces. the blank
$ key set name * @ param string | array $ value */public function zadd ($ key, $ value) {return $ this-> redis-> zadd ($ key, $ va Lue);}/*** get the corresponding element of the set * @ param string $ setName set name */public function smembers ($ setName) {return $ this-> redis-> smembers ($ setName);}/*** build a list (similar to stack) * @ param sting $ key KEY name * @ param string $ value */public function lpush ($ key, $ value) {echo "$ key-$
->rediS->zadd ($key, $value); }/** * Take collection corresponding element * @param string $setName set name */Public Function smembers ($setName) {return $ This->redis->smembers ($setName); }/** * Build a list (advanced to go, like stacks) * @param sting $key Key Name * @param string $value value */Public function Lpush ($key, $value) {echo "$key-$value \ n"; return $this->redis->lpush ($key, $value); }/** * Build a list (advanced first
---------------------------------------------------------------------
String Strtolower (String subject)//convert to lowercase
String Strtoupper (String subject)//Convert to uppercase
String Ucfirst (String subject)//Capitalize first letter
String Ucwords (String subject)//capitalize each word first letter
String LTrim (String subject)//left blank
String RTrim (String subject)//GO right blank
String trim (string subject) go left and right blank, blank includes null, tab, newline, carriage ret
); returns the character marked as index in str1. The subscript starts from 0.
(4) String. getChars ():
For example: str1.getChars (, charArray, 0); copy the substring from subscript 0 to subscript 5 in str1 to the character array charArray. The starting subscript of the character array is 0.
(5) Sting. replace ():
For example, str1.replace (oldChar, newChar); returns a new character with the same character as str1, but replaces each oldCase character
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.