Solved

java collections

Posted on 2009-05-08
1
200 Views
Last Modified: 2013-11-23
I have to  print a paper book with indexes at the end. I have a 400 pages of english text running with only (Ctrl+L) separating each page. Now i want to create index of this book just as we have at the back of the book. What java collections i would use and how would i do it?

Also after creating the index, what is the way to print the whole book
0
Comment
Question by:SunScreenCert
1 Comment
 
LVL 3

Accepted Solution

by:
hazgoduk earned 50 total points
ID: 24343205
Not quite sure what you're asking for but a LinkedHashMap could be useful if you wanted to do something like

Java - page 8-10, 12

etc assuming you know what content is on what page.
LinkedHashMap<String, String> pageIndex = new LinkedHashMap();

pageIndex.put("Java", "8-10, 12");

pageIndex.put("LinkedHashMaps", "13");
 

Iterator<String> itKeys = pageIndex.keySet().iterator();

String key = "";

String currentLetter = "";

if(itKeys.hasNext())

{

    do

    {

        key = itKeys.next();
 

        if(!key.startsWith(currentLetter)

        {

            currentLetter = key.substring(0,1);

            System.out.println("\n\n" + currentLetter + "\n");

        }
 

        System.out.println(key + ": " + pageIndex.get(key));

    }while(itKeys.hasNext());

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 23
@SBGen Method 3 38
JUnit 4 @Before and @BeforeClass differences 3 48
Java DateChooser? 3 29
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now