subject
Computers and Technology, 06.07.2021 23:50 ozieera

It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating system displays them in dictionary order, as dir1, dir10, dir11, dir12, dir2, dir3, and so on. That is irritating, and it is easy to fix. Provide a comparator that compares strings that end in digit sequences in a way that makes sense to a human. First compare the part before the digit as strings, and then compare the numeric values of the digits. Your program should work with the provided test program
DirectorySortDemo. java.
Call the class you write DirectoryComparator. java.
Submit the two files in your submission.
DirectoryComparator. java
DirectorySortDemo. java
import java. util. ArrayList;
import java. util. Arrays;
import java. util. collections;
public class DirectorySortDemo
{
public static void main (String [] args)
{
String dirNames ("dir12", "dir5", "dir9", "dirl", "dir4",
"lab10", "1ab2", "lab7", "lab17", "lab8",
"quiz8", "quiz10", "quiz11", "quiz12",
"dirll", "dir8", "dir7", "dir15", "dir3");
ArrayList directories = new
ArrayList<> (Arrays. asList (dirNames));
System. out. println ("Unsorted List:");
System. out. println (directories);
Collections. sort (directories, new DirectoryComparator ());
System. out. println ():
System. out-println ("Sorted List: ");
System. out.-println (directories);

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
Events and conditions that happen within an organization that are somewhat easier to deal with when responding to change are called
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead w 4 epizodzie
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
You know the right answer?
It is common for people to name directories as dir1, dir2, and so on. When there are ten or more dir...
Questions
question
English, 21.05.2021 01:00
question
Mathematics, 21.05.2021 01:00
Questions on the website: 13722359