20220406Java
记个笔记
字符串操作类中s1.compareTo(s)规则:
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String
object is compared lexicographically to the character sequence represented by the argument string. The result is a negative integer if this String
object lexicographically precedes the argument string. The result is a positive integer if this String
object lexicographically follows the argument string. The result is zero if the strings are equal; compareTo
returns 0
exactly when the equals(Object)
method would return true
.
This is the definition of lexicographic ordering. If two strings are different, then either they have different characters at some index that is a valid index for both strings, or their lengths are different, or both. If they have different characters at one or more index positions, let k be the smallest such index; then the string whose character at position k has the smaller value, as determined by using the <
operator, lexicographically precedes the other string. In this case, compareTo
returns the difference of the two character values at position k
in the two string -- that is, the value:
this.charAt(k)-anotherString.charAt(k)
If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case, compareTo
returns the difference of the lengths of the strings -- that is, the value:
this.length()-anotherString.length()
1.当字符串s1和s都表示数字时,有三种结果-1(代表s1<s) , 0(代表s与s1相等) ,1(代表s1>s)。
2.当字符串s1和s不表示数字时,有三种结果负整数 (代表s1和s中的第一个不相同的字符的Unicode值相减为负数),0(代表s与s1相等) ,
正整数(代表s1和s中的第一个不相同的字符的Unicode值相减为正数);若s1包含s(即s中的字符,s1都有),也有上述三种结果
但意义不同(除0表示相等)其中正整数表示s1包含s且长度大于s;反之为负整数。
3.Unicode中 a表示61 A表示41其它字母类推。
最后总结英语是有必要学的!
20220406Java的更多相关文章
随机推荐
- web自动化之selenium(四)元素等待
隐式等待 说明 隐式等待是通过设置一定时长的等待,让页面上的某些元素能过加载出来,如果超过了设置的时间还没有加载出来则抛出(NoSuchelementException异常),默认单位为"秒 ...
- LGP3449题解
其实每个串都不是回文串也能做的说... 题意:给定 \(n\) 个互不相同的串,两两拼接一共能够拼出 \(n^2\) 个串,问这 \(n^2\) 个串中有几个回文串. 首先假设拼接出来的串是 \(AB ...
- 命令行安装django以及新建项目及应用
1:安装django项目,使用pip命令进行安装,默认安装的是最高版本,可以使用pip install django==1.1.11进行指定版本安装 2:新建django项目 2.1:首先切换到创建项 ...
- 使用Xtrabackup 备份mysql数据库
##创建逻辑卷 [root@node1 ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully create ...
- spinlock 设计的初衷,当只有单核时是否还需要锁
自旋锁,的设计初衷是什么,是为了解决什么问题.如果只有一个cpu,并且是单核,那是否还需要用到自旋锁.
- Redis的Unable to connect to Redis和java.io.IOException: 远程主机强迫关闭了一个现有的连接问题的解决
学习项目xhr系统用到springboot + vue(https://github.com/lenve/vhr),文档中要求使用到RabbitMQ,但是从我搭建开发环境来看,是否配置Rabbit ...
- 常见的url编码
URL编码值 字符 %20 空格 %22 " %23 # %25 % %26 &; %28 ( %29 ) %2B + %2C , %2F / %3A : %3B ; %3C < ...
- CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes!) A ~ D
A. 给定一个序列,对于任意1<=k<=n 都满足|ai−ak|+|ak−aj|=|ai−aj|, 找满足条件的i和j并输出 思路: 观察样例,发现输出的是最大值和最小值,那么猜答案是最大 ...
- Jpa 在CriteriaBuilder中添加where条件NotIn子查询
final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery<Person> cq ...
- JPA、JTA、XA相关索引
JPA和分布式事务简介:https://www.cnblogs.com/onlywujun/p/4784233.html JPA.JTA与JMS区别:https://www.cnblogs.com/y ...