记个笔记

字符串操作类中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. Hadoop之Mapreduce 程序

    package com.gylhaut.hadoop.senior.mapreduce; import java.io.IOException; import java.util.StringToke ...

  2. Debian与Ubuntu到底有什么不同,应该如何选择?

    镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 在CentOS转向CentOS Stream之后,这意味着它将变得不可靠. 但是幸好,仍然有非常优秀的Linux发行版本在等我们.其中比较有知名度 ...

  3. Skye无人机刷Betaflight详细图文教程

    ​前言 首先十分感谢B站TASKBL up主的视频教程以及他的耐心指导,视频链接Skye 原机主板刷BetaFlight 参考教程_哔哩哔哩_bilibili.整个改造过程耗时三天,现把改造过程以及遇 ...

  4. FOC实现概述

    FOC原理框图如下: 其中涉及到两种坐标转换: 1. Clark变换:常规的三相坐标系→静止的二相坐标系α.β 正变换矩阵 $\left[ {\begin{array}{*{20}{c}}{\sqrt ...

  5. 三面面试官:运行 npm run xxx 的时候发生了什么?

    事情是这样的,直接开讲 面试官:npm run xxx的时候,发生了什么?讲的越详细越好. 我(心想,简单啊): 首先,DNS 解析,将域名解析成 IP 地址,然后 TCP 连接,TCP 三次握手.. ...

  6. ShardingSphere-Proxy(一)

    1.现实中的问题 我们知道数据库的数据,基本80%的业务是查询,20%的业务涵盖了增删改,经过长期的业务变更和积累数据库的数据到达了一定的数量之后,直接影响的是用户与系统的交互,查询时的速度,插入数据 ...

  7. 数据结构 - 顺序表 C++ 实现

    顺序表 此处实现的顺序表为**第一个位置为 data[0] **的顺序表 顺序表的定义为 const int MAX = 50; typedef int ElemType; typedef struc ...

  8. 半吊子菜鸟学Web开发5 -- PHP开发环境配置

    本文参考自:http://blog.csdn.net/angon823/article/details/54415855 Ubuntu16.04 默认 apt-get install apache2  ...

  9. 你是怎么看Spring框架的?

    Spring是一个轻量级的容器,非侵入性的框架.最重要的核心概念是IOC,并提供AOP概念的实现方式,提供对持久层,事务的支持,对当前流行的一些框架(Struts,Hibernate,MVC),Spi ...

  10. python django对数据表的增删改查操作

    新增操作:方式1:book = BookInfo(title='西游记',price=99)book.save() 方式2:BookInfo.objects.create(title='西游记',pr ...