记个笔记

字符串操作类中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. Java学习笔记:01面向对象-继承

    01面向对象-继承 一.java中的数据类型 1.基本数据类型:四类 八种 byte(1) boolean(1) short(2) char(2) int(4) float(4) long(8) do ...

  2. IEAD关于git配置以及拉代码和提交代码

    1.提前安装git客户端,注册码云帐号 注册地址:https://gitee.com/signup 2.新建仓库 3.修改仓库信息 4.从IDEA拉git项目,下面两个地方都可以配置 首次创建需要输入 ...

  3. WinDbg调试托管程序环境问题总结

    基本环境搭建及安装 安装 有2个方式可以安装WinDbg. 新版 安装WinDbg Preview 在商店里搜WinDbg直接就可以安装,这里安装的版本是x64版本.x64版本的WinDbg其实是可以 ...

  4. Intel Quartus Prime Pro Edition 权限提升漏洞

    受影响系统:Intel Quartus Prime Pro Edition < 19.3描述:CVE(CAN) ID: CVE-2019-14603 Intel Quartus Prime Pr ...

  5. K8S 如何隐藏产品TomCat版本信息

    k8s隐藏TomCat版本信息,通过sidecar方式初始化修改server.xml文件,并挂载到容器中 1.添加initcontainers initContainers: - name: conf ...

  6. _u32定义

    驱动开发的原则: 能用__u32就最好用它,或者用u_int32_t之类的也可以,但不要直接用unsigned int等默认的数据类型.目的是让别人明白,你这个变量占多大内存. 原因: 1.你不能确定 ...

  7. Vue中import和require的对比

    Vue中import和require的对比 一.前言 ​ vue框架想必是我们前端朋友们必学的知识点,说它难也没有那么难,说简单也没有那么简单,主要技术就是那么几个,可是里面的细节很多,有些时候我们会 ...

  8. Linux C申请内存三种基本方式

    一份代码可以知道具体方式和原理: int main() { int stack_a; int stack_b; static int static_c; static int static_d; in ...

  9. 为什么枚举单例在 Java 中更好?

    枚举单例是使用一个实例在 Java 中实现单例模式的新方法.虽然Java中的单例模式存在很长时间,但枚举单例是相对较新的概念,在引入Enum作为关键字和功能之后,从Java5开始在实践中.本文与之前关 ...

  10. Mybatis 的一级、二级缓存?

    1)一级缓存: 基于 PerpetualCache 的 HashMap 本地缓存,其存储作用域为 Session,当 Session flush 或 close 之后,该 Session 中的所有 C ...