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

  • Home
  • SEARCH
  • 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 7413281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:40:17+00:00 2026-05-29T06:40:17+00:00

try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println(Enter the continent;); String CN =

  • 0
 try {


    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the continent;");
    String CN = in.readLine();
    String MaxDate="1";
    for(Earthquakerecd e : eqList)
    {
        if( e.getContinent().equals("CN"))
        {
          MaxDate=e.getDate();
        }

        {
            System.out.println( e.toString()); 
        }


    }

     System.out.println( MaxDate); 
    }

    catch (IOException e)
    {
        System.out.println("IOException has been caught");
    }

This is a simple problem i think. In this problem Maxdate is declared as 1. CN is a string for continent . If the user input matches the continent , then the date should be passed from e.getDate() to Maxdate. In anycase , we should never get the output as 1 , it should be some date from object e. I am always getting 1 for Maxdate. Any possible solutions? is my syntax right?

  • 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-29T06:40:18+00:00Added an answer on May 29, 2026 at 6:40 am

    Seems like you want:

    if(e.getContinent().equals(CN))
    

    Right now you are comparing against the String literal “CN”. You aren’t using the variable CN for anything.

    I’m assuming you meant to insert an else after your if statement?

    Also, in Java it’s common to not start your variable names with uppercase letters (name your string cn instead of CN).

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

Sidebar

Related Questions

BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(Enter the String:); String str = br.readLine();//error: must
Scanner s = null; try { s = new Scanner(new BufferedReader(new FileReader(rates.txt))); for (int
public static void main(String[] args) { staples[] stemp = new staples[8]; int j; try
try { final List<String> ar = new ArrayList<String>(); final PRIvariable pri = new PRIvariable();
try { ... } catch (SQLException sqle) { String theError = (sqle).getSQLState(); ... }
Try to see which cast is faster (not necessary better): new c++ case or
try it out: volatile float bob = -344.0f; unsigned int fred = (unsigned int)bob;
I'm creating a list of items from a file BufferedReader reader = new BufferedReader(
When I try to convert a string to int array, i get a Null
I have the following host package clserver; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import

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.