String类基础知识

1、String类的构造方法

(1)String(String original)  //把字符串数据封装成字符串对象

(2)String(char[] c)   //把字符数组的数据封装成字符串对象

(3)String(char[] c, int index, int count)  // 把字符数组中的一部分数据封装成字符串对象

 

示例:

 1 public class Demo01 {
 2     public static void main(String[] args) {
 3 
 4         String str01=new String("hello");
 5 
 6         char[] c1=new char[]{'h','e','l','l','o'};
 7         String str02=new String(c1);
 8 
 9         char[] c2=new char[]{'h','e','l','l','o','w','o','r','l','d'};
10         String str03=new String(c2,0,5);
11 
12         System.out.println(str01);
13         System.out.println(str02);
14         System.out.println(str03);
15         
16     }
17 }

输出位:

hello
hello
hello

 

2、String类常用方法

(1)public boolean equals(Object obj)

将此字符串与指定的对象比较。若内容相等,返回true,否则,返回false。

equal 和 == 的区别:

  equal:比较的是值是否相同

  ==:比较的是地址值是否相同

示例:

 1 public class demo01 {
 2 
 3     public static void main(String[] args) {
 4         String s1="helloworld";
 5         String s2="hello";
 6         String s3="world";
 7         s2=s2+s3;
 8 
 9         boolean aBoolean1=s1==s2;
10         boolean aBoolean2=s1.equals(s2);
11         System.out.println("s1:"+s1+"   s2:"+s2);
12         System.out.println(aBoolean1);
13         System.out.println(aBoolean2);
14     }
15 }

输出结果为:

s1:helloworld   s2:helloworld
false
true

(2)public boolean equalIgnoreCase(String otherString)

将此 String 与另一个 String 比较,不考虑大小写。如果两个字符串的长度相同,并且其中的相应字符都相等(忽略大小写),则认为这两个字符串是相等的。 

示例:

 1 public class demo02 {
 2     public static void main(String[] args) {
 3         String s1="hello world!";
 4         String s2="Hello World!";
 5 
 6         boolean aBoolean1=s1.equals(s2);
 7         boolean aBoolean2=s1.equalsIgnoreCase(s2);
 8 
 9         System.out.println("s1:"+s1+"  s2:"+s2);
10         System.out.println("s1.equal(s2):"+aBoolean1);
11         System.out.println("s1.equalIgnoreCase(s2):"+aBoolean2);
12     }
13 }

输出结果为:

s1:hello world!  s2:Hello World!
s1.equal(s2):false
s1.equalIgnoreCase(s2):true

 

(3)public boolean startsWith(String str)

判断字符串对象是否以指定的str开头

示例:

 1 public class Demo04 {
 2     public static void main(String[] args) {
 3         String s="hello world!";
 4 
 5         boolean b1=s.startsWith("helo");
 6         boolean b2=s.startsWith("hell");
 7 
 8         System.out.println(b1);
 9         System.out.println(b2);
10     }
11 }

输出为:

false
true

(4)public boolean endsWith(String str)

判断字符串对象是否以指定的str结尾

 示例:

 1 public class Demo05 {
 2     public static void main(String[] args) {
 3         String s="hello world!";
 4 
 5         boolean b1=s.endsWith("ld!");
 6         boolean b2=s.endsWith("d!");
 7 
 8         System.out.println(b1);
 9         System.out.println(b2);
10     }
11 }

输出为:

true
true

 

(5)public int length()

获取字符串的长度,其实也就是字符个数

(6)public char charAt(int index)

获取指定索引处的字符

(7)public int indexOf(String str)

获取str在字符串对象中第一次出现的索引

 示例:

 1 public class Demo06 {
 2     public static void main(String[] args) {
 3         String str="hello world! this is me";
 4 
 5         System.out.println("字符串\"hello world! this is me\"的长度为:"+str.length());
 6 
 7         char c=str.charAt(2);
 8         System.out.println("位于字符串str,索引为2的字符为:"+c);
 9 
10         int index=str.indexOf("ll");
11         System.out.println("\"ll\"在字符串str的索引位置是:"+index);
12 
13         
14     }
15 }

输出为:

字符串"hello world! this is me"的长度为:23
位于字符串str,索引为2的字符为:l
"ll"在字符串str的索引位置是:2

(8)public String substring(int start)

从start开始截取字符串

(9)public String substring(int start,int end)

从start开始,到end结束截取字符串。包括start,不包括end

(10)public char[] toCharArray()

把字符串转换为字符数组

(11)public String toLowerCase()

把字符串转换为小写字符串

(12)public String toUpperCase()

把字符串转换为大写字符串

(13)public String trim()

将去除字符串两端空格 

(13)public String[] split (String str)

 按照指定符号分割字符串 

 

 

转载于:https://www.cnblogs.com/hanlk/p/11222033.html

内容概要:本文介绍了ENVI Deep Learning V1.0的操作教程,重点讲解了如何利用ENVI软件进行深度学习模型的训练与应用,以实现遥感图像中特定目标(如集装箱)的自动提取。教程涵盖了从数据准备、标签图像创建、模型初始化与训练,到执行分及结果优化的完整流程,并介绍了精度评价与通过ENVI Modeler实现一键化建模的方法。系统基于TensorFlow框架,采用ENVINet5(U-Net变体)架构,支持通过点、线、面ROI或分图生成标签数据,适用于多/高光谱影像的单一别特征提取。; 适合人群:具备遥感图像处理基础,熟悉ENVI软件操作,从事地理信息、测绘、环境监测等相关领域的技术人员或研究人员,尤其是希望将深度学习技术应用于遥感目标识别的初学者与实践者。; 使用场景及目标:①在遥感影像中自动识别和提取特定地物目标(如车辆、建筑、道路、集装箱等);②掌握ENVI环境下深度学习模型的训练流程与关键参数设置(如Patch Size、Epochs、Class Weight等);③通过模型调优与结果反馈提升分精度,实现高效自动化信息提取。; 阅读建议:建议结合实际遥感项目边学边练,重点关注标签数据制作、模型参数配置与结果后处理环节,充分利用ENVI Modeler进行自动化建模与参数优化,同时注意软硬件环境(特别是NVIDIA GPU)的配置要求以保障训练效率。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值