In the Java textbook that I am studying, he says that “lexicographical ordering” is used for the “whole”. I understand how it works, but in what specific way is it used in programming?
All built-in sorting methods use it when sorting non-primitives.
Let's say you wanted to sort the glasses of water, the objects themselves are called Glass.
Glass
Now let's say that a Glasscan have the height and amount of water that it holds.
, Glasses. ?
Glasses
, compareTo. , , . , , .
compareTo
, , , , , , re .
String s, . < 0, = 0 > 0 , String .
String
< 0
= 0
> 0
compareTo() - - Java.
, , <, == > . ( , , equals() moreThan() .)
, . :
, TreeSet TreeMap ( ).
.
, . , .
compareTo int, , , .
, Comparable . Java, , (String, Double, BigInteger,...).
compareTo :
:http://leepoint.net/notes-java/data/expressions/22compareobjects.htmlhttp://www.javapractices.com/topic/TopicAction.do?Id=10
This most common use is a comparison function when sorting a list of strings. One call compareToindicates whether one line goes before another, after another, or the same as on the other line.
Source: https://habr.com/ru/post/1713267/More articles:How can I make a tray icon in Linux using C ++? - c ++OpenGL Alpha mixes with the wrong color - c ++User actions such as social networks facebook, myspace, all big - phpIn Django, how do you create a set of forms manually in a template? - djangoRegarding remote debugging on the MCF5485EVB using Eclipse CDT - debuggingCan I fully force a TFS check? - tfsStaff Web Services Structure - c ++Flex, Flexunit: How to check that an event is sent twice? - flexSharing SQL queries among a command - sqlWhere can I place the Office Add-in configuration pages? - user-interfaceAll Articles