记个笔记

字符串操作类中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的更多相关文章

随机推荐

  1. CF587F&CF547E题解

    这两道题好像啊 贡献一种使用SAM和ACAM草两道题的方法 下面假装有 \(O(\sum |S|=m)=O(n)\). 你看看,这CF换过多少个出题人啦?换汤不换药啦!其实这两道题是同一个人出的 CF ...

  2. [差分数组] LeetCode789 得分最高的最小轮调

    LeetCode 得分最高的最小轮调 今天当然CV了因为今天比较忙,所以直接走算法,因为什么都不做的话并不符合社会主义核心价值观,今天小学一手查分数组. 题目:并不存在CV了还写什么题解 算法背景: ...

  3. 老徐和阿珍的故事:Runnable和Callable有什么不同?

    人物背景: 老徐,男,本名徐福贵,从事Java相关研发工作多年,职场老油条,摸鱼小能手,虽然岁数不大但长的比较着急,人称老徐.据说之前炒某币败光了所有家产,甚至现在还有欠债. 阿珍,女,本名陈家珍,刚 ...

  4. 三极管与MOS管主要参数差别及驱动电路基极(栅极)串联电阻选取原则

    三极管与MOS管都常在电路中被当做开关使用,比较起来: 1. 三极管集电极电流IC (一般为mA级别),远小于MOS管ID(一般为A级别),因此MOS管多用在大电流电路中,如电机驱动 2. 三极管耗散 ...

  5. [NPUCTF2020]Baby Obfuscation wp

    整体观察main函数,可以发现用户自定义函数和变量存在混淆,猜测为函数名及变量名asc混淆. 对函数进行分析: Fox1为欧几里得算法求最大公约数 Fox5其实是pow Fox4根据逻辑数学的法则实际 ...

  6. 深入浅出SpringBoot

  7. 七牛云简单实用-uploadManager.put(..)抛出异常

    描述: 本人小白,最近在写一个仿头条的项目,其中有用到七牛云做为图片的存储以代替本地服务其存储,按照视频教程配置服务器端的简单上传功能,总是报错: 参照官方文档:https://developer.q ...

  8. MariaDB 存储引擎一览(官方文档翻译)

    inline-translate.translate { } inline-translate.translate::before, inline-translate.translate::after ...

  9. 面试问题之操作系统:Linux下进程的内存结构

    转载于:http://www.hqj.com/news/emb184.htm Linux操作系统采用虚拟内存管理技术,使得每个进程都有各自互不干涉的进程地址空间.该地址空间是大小为4GB的线性虚拟空间 ...

  10. Zookeeper 的典型应用场景 ?

    Zookeeper 是一个典型的发布/订阅模式的分布式数据管理与协调框架,开发人员 可以使用它来进行分布式数据的发布和订阅. 通过对 Zookeeper 中丰富的数据节点进行交叉使用,配合 Watch ...