C++string类

文章目录

  • C++string类
    • 一、string基本概念
    • 二、string初始化
      • (1)构造函数
      • (2)默认构造函数
      • (3)复制构造函数
    • 三、string的输入输出
      • (1)输入
      • (2)输出
    • 四、string的赋值
      • (1)用 = 赋值
      • (2)用 assign 成员函数复制
    • 五、string的连接
      • (1)用 + 、+=运算符连接字符串
      • (2)用成员函数 append 连接字符串
    • 六、string元素存取 (访问)
      • (1)下标操作符 [ ]
      • (2)成员函数at()
    • 七、string大小和容量
    • 八、string的比较
      • (1)`>` 、 `<` 、 `==` 、 `>=` 、`<=`、 `!=` 等比较运算符
      • (2)compare()函数
    • 九、string的查找
      • (1)find ()函数和 rfind()函数
      • (2)find_first_of ()函数和 find_last_of ()函数
      • (3)find_first_not_of ()函数和find_last_not_of ()
      • (4)查找代码示例
    • 十、string内容的修改和替换
      • (1)string类的替换函数
      • (2)string类的插入函数
      • (3)string类的删除函数
    • 十一、常用操作
      • string的子串
      • string的交换
    • 十二、string类的迭代器处理
      • (1)正向迭代
      • (2)反向迭代
    • 十三、字符串流处理
      • (1)字符串流处理 - 字符串输入流 istringstream
      • (2)字符串流处理 - 字符串输出流 istringstream
    • 十四、转换成C语言式char *字符串
      • (1)成员函数 c_str()
      • (2)成员函数data()
      • (3)成员函数copy()

一、string基本概念

  • string 类是模板类:

    typedef basic_string<char> string;
    
  • 字符串类模板 (basic string)
    标准库字符串功能的基础是 basic string,该类模板提供了许多成员和函数, 与标准容器 类似。该类模板的声明如下:

    template <class Ch, class Tr = char_traits<Ch>, class A = allocator<Ch>>
    class std::basic_string
    {public:…
    }
    

    在上述模板声明中,第一个参数(class Ch)是说明单个字符(Ch)所属型别(class);第二个参数 (class Tr = char traits < Ch > ) 是特性类别, 用以提供字符串类别中的所有字符 核心操作。 该特性类别规定了 “复制字符” 或 “比较字符” 的做法; 如果不指定该特性类别,系统会根据现有的字符型别采用默认的特性类别。 第三个参数带有默认值(class A = allocator < Ch > ), 用以定义字符串类别所采用的内存模式, 通常设定为 “默认内存模型 al- locator”。 该模板及其相关功能都定义在名称空间 std 中, 由头文件 < string > 给出。

  • string 类的所有成员函数

函 数 名 称 效 果
构造函数 产生或复制字符串
析构函数 销毁字符串
= , assign 赋以新值
Swap 交换两个字符串的内容
+ = , append(), push_back() 添加字符
insert() 插入字符
erase() 删除字符
clear() 移除全部字符
resize() 改变字符数量
replace() 替换字符
串联字符串
== ,!= ,<,<=,>,>=,compare() 比较字符串内容
size(), length() 返回字符数量
max_size() 返回字符的最大可能个数
empty() 判断字符串是否为空
capacity() 返回重新分配之前的字符容量
reserve() 保留内存以存储一定数量的字符
[], at() 存取单一字符
>> , getline() 从 stream 中读取某值
<< 将值写入 stream
copy() 将内容复制为一个 C - string
c_str() 将内容以 C - string 形式返回
data() 将内容以字符数组形式返回
substr() 返回子字符串
find() 搜寻某子字符串或字符
begin(), end() 提供正向迭代器支持
rbegin(), rend() 提供逆向迭代器支持
get_allocator() 返回配置器

二、string初始化

(1)构造函数

  • 生成字符串 str 的复制品

    • 函数说明

      string s(str) //str是string类型量
      
    • 函数示例

      string str="hello world";
      string s(str);
      cout<<s;
      

      输出:
      hello world

  • 将字符串 str 中始于 stridx 的部分作为构造函数的初值

    • 函数说明

      string s(str, stridx) // str是string类型量,stridx是起始位置下标
      
    • 函数示例

      string str="hello world";
      string s(str, 6);
      cout<<s;
      

      输出:
      world

  • 将字符串 str 中始于 strbegin、长度为 strlen 的部分作为字符串初值

    • 函数说明

      string s(str, strbegin, strlen) //str是字符串,strbegin是起始位置下标,strlen是字符串长度
      
    • 函数示例

      char *str = "hello world";
      string s(str, 2, 3);
      cout << s;
      

      输出:
      llo

  • 以 C_string 类型 cstr 作为字符串 s 的初值

    • 函数说明

      string s(cstr) //cstr是字符数组或字符串常量
      
    • 函数示例

      char *str = "hello world";
      string s(str);
      cout << s;
      

      输出:
      hello world

  • 以 C_string 类型 cstr 的前 char_len 个字符串作为字符串 s 的初值

    • 函数说明

      string s (cstr, char_len) //cstr是字符数组或字符串常量,char_len是长度
      
    • 函数示例
      char str[] = "hello world";
      string s(str, 6);
      cout << s;
      

      输出
      hello

  • 生成一个字符串, 包含 num 个 c 字符

    • 函数说明

      string s (num, c) //num是int型变量,c是字符
      
    • 函数示例
      string s(3, '6');
      cout << s
      

      输出:
      666

  • 以区间 [beg, end] 内的字符作为字符串 s 的初值

    • 函数说明

      string s ( beg, end) //beg,end均为迭代器
      
    • 函数示例
      string str = "hello world";
      string::iterator i=str.begin();
      string s(i,i+3);
      cout << s;
      

      输出:
      hel

(2)默认构造函数

  • 生成空字符串

    string s;
    

    若不提供分配器,则从默认构造的实例获得分配器。

(3)复制构造函数

当构造的string太长而无法表达时会抛出length_error异常

string s2 = "hello";

三、string的输入输出

(1)输入

  • string 支持流读取运算符

    string类重载运算符operator>>用于输入;
    cin>>s; 读入s,遇到空格或回车停止,无论原先s是什么内容都会被新读入的数据替代

    string s;
    getline(cin ,s);
    
  • string 支持getline函数

    函数getline(istream &in,string &s);用于从输入流in中读取字符串到s中,以换行符’\n’分开。

    string stringObject;
    cin >> stringObject;
    

(2)输出

重载运算符operator<<用于输出操作。

cout << s;

四、string的赋值

(1)用 = 赋值

string &operator=(const string &s);把字符串s赋给当前字符串

string s = "hello"
string s1;
s1 = s;

(2)用 assign 成员函数复制

  • 函数示例

    • 用 assign 成员函数复制

      string s1("cat"), s3;
      s3.assign(s1);
      
    • 用 assign 成员函数部分复制

      string s1("catpig"), s3;
      s3.assign(s1, 1, 3);
      

      从s1 中下标为1的字符开始复制3个字符给s3

  • 函数说明

    • 用c类型字符串s赋值

      string &assign(const char *s);
      
    • 用c字符串s开始的n个字符赋值

      string &assign(const char *s,int n);
      
    • 把字符串s赋给当前字符串

      string &assign(const string &s);
      
    • 用n个字符c赋值给当前字符串

      string &assign(int n,char c);
      
    • 把字符串s中从start开始的n个字符赋给当前字符串

      string &assign(const string &s,int start,int n);
      
    • 把first和last迭代器之间的部分赋给字符串

      string &assign(const_iterator first,const_itertor last);
      

五、string的连接

(1)用 + 、+=运算符连接字符串

  • 重载说明

    string &operator+=(const string &s);
    

    把字符串s连接到当前字符串的结尾

  • 运用举例:

    string s1("good "), s2("morning! ");
    s1 += s2;
    cout << s1;
    

    输出:
    good morning!

(2)用成员函数 append 连接字符串

  • 函数示例

    string s1("good "), s2("morning! ");
    s1.append(s2);
    cout << s1;
    s2.append(s1, 3, s1.size()); //s1.size(),s1字符数
    cout << s2;
    

    下标为3开始,s1.size()个字符,如果字符串内没有足够字符,则复制到字符串最后一个字符

  • 函数说明

    • 把c类型字符串s连接到当前字符串结尾

      string &append(const char *s);
      
    • 把c类型字符串s的前n个字符连接到当前字符串结尾
      string &append(const char *s,int n);
      
    • 同operator+=()
      string &append(const string &s);
      
    • 把字符串s中从pos开始的n个字符连接到当前字符串的结尾
      string &append(const string &s,int pos,int n);
      
    • 在当前字符串结尾添加n个字符c
      string &append(int n,char c);
      
    • 把迭代器first和last之间的部分连接到当前字符串的结尾
      string &append(const_iterator first,const_iterator last);
      

六、string元素存取 (访问)

(1)下标操作符 [ ]

  • 操作符说明

    下标操作符 []在使用时不检查索引的有效性。如果下标超出字符的长度范围,会导致未定义行为;对于常量字符串,使用下标操作符时,字符串的最后字符 (即 '\0') 是有效的。 对应 string 类型对象 (常量型) 最后一个字符的下标是有效的,调用返回字符 '\0'

  • 操作符示例

    string s1("Hello");
    s1[3] = 'a';
    

(2)成员函数at()

  • 函数说明

    函数 at() 在使用时会检查下标是否有效。 如果给定的下标超出字符的长度范围, 系统 会抛出 out of range 异常。

  • 函数示例

    string s1("Hello");
    for(int i=0;i<s1.length();i++)cout << s1.at(i) << endl;
    

    逐个访问string对象中的字符

七、string大小和容量

  • size()和 length()

    int size()const;
    
    int length()const;
    

    size()和 length()。 这两个函数会返回 string 类型对象中的字符个数,且它们的执行效果相同。

  • max_size()

    int max_size()const;
    

    max_size()函数返回 string 类型对象最多包含的字符数。 一旦程序使用长度超过 max_size()的 string 操作, 编译器会抛出 length_error 异常。

  • capacity()

    int capacity()const;
    

    该函数返回在重新分配内存之前, string 类型对象所能包含的最大字符数。

  • reserve()

    调用该函数可以为 string 类型对象重新分配 内存。 重新分配的大小由其参数决定。 reserve() 的默认参数为 0。

  • empty()

    bool empty()const;
    

    当前字符串是否为空

  • resize

    void resize(int len,char c);
    

    把字符串当前大小置为len,并用字符c填充不足的部分

八、string的比较

(1)==>=<=!= 等比较运算符

  • 比较两个字符串是否相等

    bool operator==(const string &s1,const string &s2)const;
    

    运算符">","<",">=","<=","!="均被重载用于字符串的比较;

(2)compare()函数

compare函数在>时返回1,<时返回-1,==时返回0

  • 比较当前字符串和s的大小

    int compare(const string &s) const;
    
  • 比较当前字符串从pos开始的n个字符组成的字符串与s的大小

    int compare(int pos, int n,const string &s)const;
    
  • 比较当前字符串从pos开始的n个字符组成的字符串与s中pos2开始的n2个字符组成的字符串的大小

    int compare(int pos, int n,const string &s,int pos2,int n2)const;
    
  • 与字符数组的比较

    int compare(const char *s) const;
    int compare(int pos, int n,const char *s) const;
    int compare(int pos, int n,const char *s, int pos2) const;
    

九、string的查找

(1)find ()函数和 rfind()函数

  • find()

    • 从pos开始查找字符c在当前字符串的位置

      int find(char c, int pos = 0) const;
      
    • 从pos开始查找字符串s在当前串中的位置

      int find(const char *s, int pos = 0) const;
      
    • 从pos开始查找字符串s中前n个字符在当前串中的位置

      int find(const char *s, int pos, int n) const;
      
    • 从pos开始查找字符串s在当前串中的位置

      int find(const string &s, int pos = 0) const;
      
  • rfind()

    • 返回最后一个与str中的某个字符匹配的字符,从index开始查找。如果没找到就返回string::npos

      size_type rfind( const basic_string &str, size_type index );
      
      size_type rfind( const char *str, size_type index );
      
    • 返回最后一个与str中的某个字符匹配的字符,从index开始查找,最多查找num个字符。如果没找到就返回string::npos

      size_type rfind( const char *str, size_type index, size_type num );
      
    • 返回最后一个与ch匹配的字符,从index开始查找。如果没找到就返回string::npos

      size_type rfind( char ch, size_type index );
      

(2)find_first_of ()函数和 find_last_of ()函数

  • find_first_of ()

    • 查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,如果没找到就返回string::npos

      size_type find_first_of( const basic_string &str, size_type index = 0 );
      
      size_type find_first_of( const char *str, size_type index = 0 );
      
    • 查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回string::npos

      size_type find_first_of( const char *str, size_type index, size_type num );
      
    • 查找在字符串中第一个与ch匹配的字符,返回它的位置。搜索从index开始

      size_type find_first_of( char ch, size_type index = 0 );
      
  • find_last_of ()

    • 在字符串中查找最后一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_last_of( const basic_string &str, size_type index = npos );
      
      size_type find_last_of( const char *str, size_type index = npos );
      
    • 在字符串中查找最后一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回string::nops

      size_type find_last_of( const char *str, size_type index, size_type num );
      
    • 在字符串中查找最后一个与ch匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_last_of( char ch, size_type index = npos );
      

(3)find_first_not_of ()函数和find_last_not_of ()

  • find_first_not_of ()

    • 在字符串中查找第一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_first_not_of( const basic_string &str, size_type index = 0 );
      
      size_type find_first_not_of( const char *str, size_type index = 0 );
      
    • 在字符串中查找第一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始,最多查找num个字符。如果没找到就返回string::nops

      size_type find_first_not_of( const char *str, size_type index, size_type num );
      
    • 在字符串中查找第一个与ch不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_first_not_of( char ch, size_type index = 0 );
      
  • find_last_not_of ()

    • 在字符串中查找最后一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_last_not_of( const basic_string &str, size_type index = npos );
      
      size_type find_last_not_of( const char *str, size_type index = npos);
      
    • 在字符串中查找最后一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始,最多查找num个字符如果没找到就返回string::nops

      size_type find_last_not_of( const char *str, size_type index, size_type num );
      
    • 在字符串中查找最后一个与ch不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回string::nops

      size_type find_last_not_of( char ch, size_type index = npos );
      

(4)查找代码示例

string s1("hello worlld");
cout << s1.find("ll") << endl;
cout << s1.find("abc") << endl;
cout << s1.rfind("ll") << endl;
cout << s1.rfind("abc") << endl;
cout << s1.find_first_of("abcde") << endl;
cout << s1.find_first_of("abc") << endl;
cout << s1.find_last_of("abcde") << endl;
cout << s1.find_last_of("abc") << endl;
cout << s1.find_first_not_of("abcde") << endl;
cout << s1.find_first_not_of("hello world") << endl;
cout << s1.find_last_not_of("abcde") << endl;
cout << s1.find_last_not_of("hello world") << endl;

输出:
2
4294967295
9
4294967295
1
4294967295
11
4294967295
0
4294967295
10
4294967295

十、string内容的修改和替换

(1)string类的替换函数

  • replace()函数说明

    • 用str中的num个字符替换本字符串中的字符,从index开始

      basic_string &replace( size_type index, size_type num, const basic_string &str );
      
    • 用str中的num2个字符(从index2开始)替换本字符串中的字符,从index1开始,最多num1个字符

      basic_string &replace( size_type index1, size_type num1, const basic_string &str, size_type index2,size_type num2 );
      
    • 用str中的num个字符(从index开始)替换本字符串中的字符

      basic_string &replace( size_type index, size_type num, const char *str );
      
    • 用str中的num2个字符(从index2开始)替换本字符串中的字符,从index1开始,num1个字符

      basic_string &replace( size_type index, size_type num1, const char *str, size_type num2 );
      
    • 用num2个ch字符替换本字符串中的字符,从index开始

      basic_string &replace( size_type index, size_type num1, size_type num2, char ch );
      
    • 用str中的字符替换本字符串中的字符,迭代器start和end指示范围

      basic_string &replace( iterator start, iterator end, const basic_string &str );
      
      basic_string &replace( iterator start, iterator end, const char *str );
      
    • 用str中的num个字符替换本字符串中的内容,迭代器start和end指示范围

      basic_string &replace( iterator start, iterator end, const char *str, size_type num );
      
    • 用num个ch字符替换本字符串中的内容,迭代器start和end指示范围

      basic_string &replace( iterator start, iterator end, size_type num, char ch );
      
  • 函数示例

    string s1("hello world");
    s1.replace(2,3, "haha");
    cout << s1;
    //将s1中下标2 开始的3个字符换成“haha”
    

    输出:
    hehaha world

(2)string类的插入函数

  • insert()函数说明

    • 在迭代器i表示的位置前面插入一个字符ch

      iterator insert( iterator i, const char &ch );
      
    • 在字符串的位置index插入字符串str

      basic_string &insert( size_type index, const basic_string &str );
      
      basic_string &insert( size_type index, const char *str );
      
    • 在字符串的位置index插入字符串str的子串(从index2开始,长num个字符)

      basic_string &insert( size_type index1, const basic_string &str, size_type index2, size_type num );
      
    • 在字符串的位置index插入字符串str的num个字符

      basic_string &insert( size_type index, const char *str, size_type num );
      
    • 在字符串的位置index插入num个字符ch的拷贝

      basic_string &insert( size_type index, size_type num, char ch );
      
    • 在迭代器i表示的位置前面插入num个字符ch的拷贝

      void insert( iterator i, size_type num, const char &ch );
      
    • 在迭代器i表示的位置前面插入一段字符,从start开始,以end结束

      void insert( iterator i, iterator start, iterator end );
      
  • 函数示例

    string s1("hello world");
    string s2("show insert");
    s1.insert(5, s2) // 将s2插入s1下标5的位置cout<< s1 << endl;
    s1.insert(2, s2, 5, 3);
    //将s2中下标5开始的3个字符插入s1下标2的位置
    cout << s1 << endl;
    

    输出:
    helloshow insert world
    heinslloshow insert world

(3)string类的删除函数

  • erase()函数说明

    • 删除pos指向的字符, 返回指向下一个字符的迭代器

      iterator erase( iterator pos );
      
    • 删除从start到end的所有字符, 返回一个迭代器,指向被删除的最后一个字符的下一个位置

      iterator erase( iterator start, iterator end );
      
    • 删除从index索引开始的num个字符, 返回*this

      basic_string &erase( size_type index = 0, size_type num = npos );
      
  • 函数示例

    string s1("hello worlld");
    s1.erase(5);
    cout << s1;
    cout << s1.length();
    cout << s1.size();
    // 去掉下标 5 及之后的字符
    

    输出:
    hello55

十一、常用操作

string的子串

  • substr函数

    string substr(int pos = 0,int n = npos) const;
    

    返回pos开始的n个字符组成的字符串

  • 函数示例

    string s1("hello world"), s2;
    s2 = s1.substr(4,5); // 下标4开始5个字符
    cout << s2 << endl;
    

    输出:
    o wor

string的交换

  • swap函数

    void swap(string &s2);
    

    交换当前字符串与s2的值

  • 函数示例

    string s1("hello world"), s2("really");
    s1.swap(s2);
    cout << s1 << endl;
    cout << s2 << endl;
    

    输出:
    really
    hello world

十二、string类的迭代器处理

string类提供了向前和向后遍历的迭代器iterator,迭代器提供了访问各个字符的语法,类似于指针操作,迭代器不检查范围。
string::iteratorstring::const_iterator声明迭代器变量,const_iterator不允许改变迭代的内容。

(1)正向迭代

  • begin()

    onst_iterator begin()const;
    iterator begin(); //返回string的起始位置
    
  • end()

    const_iterator end()const;
    iterator end(); //返回string的最后一个字符后面的位置
    

(2)反向迭代

(反向迭代器自增后指向前一个值)

  • rbegin()

     const_iterator rbegin()const;iterator rbegin();  //返回string的最后一个字符的位置
    
  • rend()

     const_iterator rend()const;iterator rend(); //返回string第一个字符位置的前面
    

十三、字符串流处理

除了标准流和文件流输入输出外,还可以从string进行 输入输出;
类似 istream和osteram进行标准流输入输出,我们用 istringstream 和 ostringstream进行字符串上的输入 输出,也称为内存输入输出。
头文件:#include <sstream>

(1)字符串流处理 - 字符串输入流 istringstream

string input("Input test 123 4.7 A");
istringstream inputString(input);
string string1, string2;
int i;
double d;
char c;
inputString >> string1 >> string2 >> i >> d >> c;
cout << string1 << endl << string2 << endl;
cout << i << endl << d << endl << c <<endl;
long L;
if(inputString >> L) cout << "long\n";
else cout << "empty\n";

输出: Input test 123
4.7 A empty

(2)字符串流处理 - 字符串输出流 istringstream

ostringstream outputString;
int a = 10;
outputString << "This " << a << "ok" << endl;
cout << outputString.str();

输出:
This 10ok

十四、转换成C语言式char *字符串

(1)成员函数 c_str()

  • 函数说明

    const char *c_str();
    

    c_str()函数返回一个指向正规C字符串的指针, 内容与本字符串相同.

  • 函数示例

    string s1("hello world");
    printf("%s\n", s1.c_str());
    

    输出:
    hello world

(2)成员函数data()

  • 函数说明

    const char *data();
    

    data()函数返回指向自己的第一个字符的指针.

  • 函数示例

    string s1("hello world");
    const char *p1 = s1.data();
    for (int i = 0; i < s1.length(); i++)printf("%c", *(p1 + i));
    //s1.data() 返回一个char * 类型的字符串,对s1 的修改可能会使p1出错
    

    输出:
    hello world

(3)成员函数copy()

  • 函数说明

    size_type copy( char *str, size_type num, size_type index );
    

    copy()函数拷贝自己的num个字符到str中(从索引index开始)。返回值是拷贝的字符数

  • 函数示例

    string s1("hello world");
    int len = s1.length();
    char *p2 = new char[len + 1];
    s1.copy(p2, 5, 0);
    p2[5] = 0;
    cout << p2 << endl;
    // s1.copy(p2,5,0) 从s1的下标0的字符开始制作一个最长5个字符长度的字符串副本并将其赋值给p2。返回值表明实际复制字符串的长度。
    

    输出:
    hello

【知识索引】【C++入门】

【C++入门】C++ string类相关推荐

  1. java实现linkstring,【JAVA SE基础篇】32.String类入门

    [JAVA SE基础篇]32.String类入门 1.字符串 1.String类又称作不可变字符序列 2.String位于java.lang包中,java程序默认导入java.lang包下所有的类 3 ...

  2. string类的erase函数属于stl吗_C++ STL快速入门

    C++ STL中最基本以及最常用的类或容器无非就是以下几个:在数月之前的机试中第一次体验到STL的威力,因为自己本来一直在用C语言做开发,很多数据结构都是自己造的,比如链表.队列等,第一次接触C++ ...

  3. 交换变量和String类初始化:JAVA入门基础

    本文主要介绍了变量交换.String类初始化.字符串的基本操作.变量交换详解介绍了两个变量是如何交换的,通过例子理解这个用法. 一.交换变量 1.什么是交换变量 例如用户输入a.b的值分别3,9的整数 ...

  4. 《java入门第一季》之类String类小案例

    String类有许多获取方法,API文档里面可查看.针对获取方法,给出小案例. /** 需求:遍历获取字符串中的每一个字符* 分析: 用到两个方法:char charAt(int index) 表示获 ...

  5. java 格式化字符串_Java入门 - 语言基础 - 14.String类

    1.概述 字符串广泛应用 在 Java 编程中,在 Java 中字符串属于对象,Java 提供了 String 类来创建和操作字符串. 2.创建字符串 创建字符串最简单的方式如下: String gr ...

  6. java unicode32_【JAVA SE基础篇】32.String类入门

    1.字符串 1.String类又称作不可变字符序列 2.String位于java.lang包中,java程序默认导入java.lang包下所有的类 3.java字符串就是Unicode字符序列,例如字 ...

  7. 百无聊赖之JavaEE从入门到放弃(十一)string类 常量池原理 内部类

    目录 一.String类和常量池 1.String基础知识 2.常量池 二.内部类 1.概念 2.内部类的作用 3.注意 4.非静态内部类 5.静态内部类 6.匿名内部类 7.局部内部类 一.Stri ...

  8. Lucene4 入门(2)–Field类及辅助类说明

    2019独角兽企业重金招聘Python工程师标准>>> Lucene4 入门(2)–Field类及辅助类说明 一.Eclipse中Field类的继承关系图: 二.Field类 1.  ...

  9. c++ 输出string_来讲讲Java中String 类的知识点

    本文来总结一下Stirng 的有关知识点 1.String中的引用 String 可以通过new和构造方法来创建一个对象,用s来引用它(也就是相当于把asdf这个字符串赋值给s String s = ...

最新文章

  1. 计算机书籍-Linux内核 入门篇
  2. c++,不能声明为虚函数的函数
  3. Kd-Tree算法原理和开源实现代码
  4. 常用 API 函数(10): 硬件与系统函数
  5. 网络之四海:光纤收发器TX、RX分别表示什么?区分单纤双纤收发器的方法
  6. Codeforces Round #726 (Div. 2) F. Figure Fixing 二分图 + 思维
  7. 万字长文丨1分36秒,100亿,支付宝技术双11答卷:没有不可能
  8. gson json转map_Java 中几种常用 JSON 库性能比较
  9. mycat分片mysql_49 mycat分片集群mysql分片分表策略
  10. python json key_最全总结 | 聊聊 Python 数据处理全家桶(配置篇)
  11. 【Java I/O流】File、字符集、字节流、字符流、缓冲流、数据流、对象流、序列化、try-with-resources语句
  12. 在windows 2008下面使用dynamipsgui
  13. box-shadow单边阴影设置
  14. 人脸识别的流行用途有哪些
  15. 推荐 10 个好用的 JavaScript 代码压缩工具
  16. MineCraft Spigot简单开服教程
  17. 自建局域网 OTA 服务器
  18. android 瀑布流 github,GitHub - youxilua/waterfall4android: android瀑布流
  19. osm数据下载 python_批量下载osm的分区域的osm文件
  20. VRRP和DHCP的设置

热门文章

  1. Cmake之基本语法
  2. ffmpeg之G711解析成pcm
  3. elementUI压缩图片和将图片转成base64格式
  4. python 标量_标量 | NumPy 中文
  5. c++字符串加密_【网络爬虫教学】快速定位拼多多加密算法入口(四)
  6. nc65 单据非向导开发 源代码_【免费毕设】ASP.NETIT产品网上物流管理信息系统的设计与实现(源代码+论文)...
  7. windows 一键安装apache服务器 windows傻瓜式安装apache2 web服务器管理软件
  8. 微信小程序 data中数据值的更改与储存
  9. Java基础教程【第二章:Java数据类型和变量】
  10. excelexportentity中设置null不显示的方法_如何在 Creator3D 中切换模型贴图,超级简单!...