记个笔记

字符串操作类中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. Android 12(S) 图形显示系统 - 初识ANativeWindow/Surface/SurfaceControl(七)

    题外话 "行百里者半九十",是说步行一百里路,走过九十里,只能算是走了一半.因为步行越接近目的地,走起来越困难.借指凡事到了接近成功,往往是最吃力.最艰难的时段.劝人做事贵在坚持, ...

  2. LGP4609题解

    题意简单明确( 很容易知道最高的位置一定是左边能看到最高的和右边能看到最高的.于是我们考虑一个 dp: 设 \(dp[n][A][B]\) 表示长度为 \(n\) 的排列,左边有 \(A\) 个 ba ...

  3. LGP7704题解

    来一个特别暴力的做法. 首先,如果删掉 \(x\) 和 \(y\) 的效果一定和删掉 \(xy\) 的效果相同,且代价一定不大于后者. 于是我们只删除质数,题目就变成了寻找 \(i!(1 \leq i ...

  4. [SWPU2019] NETWORK

    [SWPU2019]Network(TTL隐写) 1.题目概述 2.解题过程 文档中的数字代表什么呢?会不会是RGB? 看了一下以前做过的题目,好像并不是 那是什么呢?百度告诉我这是TTL隐写,哇,长 ...

  5. .NET Core剪裁器Zack.DotNetTrimmer升级瘦身引擎,并支持剪裁计划的录制和回放

    上周,我发布了对.NET Core程序进行瘦身的开源软件Zack.DotNetTrimmer,与.NET Core内置的剪裁器相比,Zack.DotNetTrimmer不仅对程序的剪裁效果更好,而且还 ...

  6. 我写的 Python 代码,同事都说好

    原文链接: 我写的 Python 代码,同事都说好 人生苦短,我用 Python. 程序员的追求就是不写代码,早日财务自由.不对,一不小心把实话说出来了,应该是将代码写得简洁,优雅. Python 程 ...

  7. 【freertos】004-任务创建与删除及其实现细节

    前言 后面都是已动态内存任务为例来分析. 注意: 由于当前学习是在linux上跑的freertos,对于freertos底层相关接口,从demo工程来看,都是posix标准相关. 鉴于freertos ...

  8. JDK8新特性关于Stream流

    在Java1.8之前还没有stream流式算法的时候,我们要是在一个放有多个User对象的list集合中,将每个User对象的主键ID取出,组合成一个新的集合,首先想到的肯定是遍历,如下: 1 2 3 ...

  9. Mybatis框架基础入门(二)--架构简介

    mybatis配置 SqlMapConfig.xml,此文件作为mybatis的全局配置文件,配置了mybatis的运行环境等信息. mapper.xml文件即sql映射文件,文件中配置了操作数据库的 ...

  10. 可以直接调用 Thread 类的 run ()方法么?

    当然可以.但是如果我们调用了 Thread 的 run()方法,它的行为就会和普通的方 法一样,会在当前线程中执行.为了在新的线程中执行我们的代码,必须使用 Thread.start()方法.