- 网络数据采集技术:Java网络爬虫实战
- 钱洋等
- 179字
- 2025-02-17 21:43:45
2.7 String类
Java使用java.lang包中的String类来创建字符串变量。另外,String类提供了操作字符串的一系列方法,表2.2列举了常用的一些方法。
表2.2 String类操作字符串常用方法

程序2-12演示了表2.2中一些方法的使用。
程序2-12

图2.12为程序2-12的输出结果。

图2.12 String类的使用
另外,调用java.lang包的其他类中的方法,可以实现String数据类型与其他数据类型的转换。如采集数据时,经常需要将字符串类型转化成整型和Double类型等(见程序2-13)。
程序2-13
