Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:15:42+00:00 2026-05-23T10:15:42+00:00

im making a java mobile app to display quotes by people. It would have

  • 0

im making a java mobile app to display quotes by people. It would have over 18000 quotes, categorized by person and number of quotes. Users of my app would enter the person number and quote number for that person. (two separate numbers). Should i use a nested switch case or an if else statement? or is there another way for doing this? maybe instead of making strings of each quote, make text files with the quotes(1 text file per person) n use a single switch case to get person n goto line no. of the text file for that person? which method would be faster n easier for the mobile it is being run on? Thanks in advance! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:15:43+00:00Added an answer on May 23, 2026 at 10:15 am

    You could load quote files on-demand and cache their quotes for use in the same session, e.g.:

    public class Quotes {
        Hashtable cache;
    
        public Quotes() {
           cache = new Hashtable();
        }
    
        public String getQuote(int person, int quoteNumber) {
            if (!cache.containsKey(new Integer(person))) {
               try {
                   loadQuoteFile(person);
               } catch (IOException e) {
                   // Invalid person / file - do what you will
               }
            }
    
            String[] quotes = (String[])cache.get(new Integer(person));
            if (quoteNumber < 0) return quotes[0];
            if (quoteNumber >= quotes.length) return quotes[quotes.length - 1];
            return quotes[quoteNumber];
        }
    
        private void loadQuoteFile(int person) throws IOException {
            String[] quotes;
            // Load the file
            // Parse into strings using linebreaks as the delimiter
            cache.put(new Integer(person), quotes);
        }
    }
    

    You’ll likely need the text file approach anyway, unless you’re keen on writing or generating code for a class containing all the quote data – e.g. a String[][], with person and quote number as indices and another String[] containing people’s names – which is another option if you have enough memory available. Getting a particular quote from such a structure would just be a case using the given numbers asarray indices (performing range chaching as you go).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a shopping list mobile application (Java ME) and i have two classes;
I am making a distributed java app for which I need both parts of
I am making an application with Java Swing and i have a problem. I
I am making a text based game in Java. I have a text field,
I'm doing some work making a Java app compatible with alternative input devices. Unfortunately,
I am interested in making mobile oriented applications. I have a basic knowledge of
Next semester we have a module in making Java applications in a team. The
I'm making a Java ME application for Symbian S60 5th edition and I have
I am making a console Java app where you can type in console commands
I have a Java program making some JNI calls to a native library (mylib.so).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.