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 9224263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:16:33+00:00 2026-06-18T04:16:33+00:00

I am having difficulty retrieving a value from a string array. I need to

  • 0

I am having difficulty retrieving a value from a string array.

I need to have it output the name of the day of the week.. i.e. Sunday for the number 0. I have the code perfect for outputting the numbers, but I can’t get it to pull from my array of day names.

import java.util.Scanner;

public class FutureDateJava {
    String[] dayStrings = { "Sunday", "Monday", "Tuesday", 
                            "Wednesday", "Thursday", "Friday", 
                            "Saturday" };

    public static void main (String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("Enter today's day: ");
        int today = input.nextInt();

        System.out.println("Enter a day in the future ");
        int future = input.nextInt();

        int futureDay = (today + future) % 7;

        System.out.print("Today is " + today + 
            " and the future day is " + futureDay);
    }
}
  • 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-06-18T04:16:34+00:00Added an answer on June 18, 2026 at 4:16 am

    Actually access the array:

    System.out.print("Today is " + dayStrings [today % 7] + " and the future day is " + dayStrings [futureDay]);
    

    The %7 is to make sure that a day (eg 10) doesn’t cause an out of bounds exception. However, this isn’t exactly optimal, it assumes that Monday is day 0, but the idea is there.

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

Sidebar

Related Questions

I'm having difficulty in retrieving values from a Json array. I have a Json
I have the following web config file. I am having some difficulty in retrieving
I'm having difficulty accessing a member of one class from another class. I have
I'm having difficulty extracting a single node value from a nodelist. My code takes
I am having difficulty figuring out how to number my subreport's records. I have
I'm having a bit of difficulty retrieving fast responds from the mysql server whilst
I am having difficulty redirecting the output from a console application to a Windows
Having difficulty grabbing data from an XML and putting it into an Array. At
I am having difficulty retrieving a comma separated list from MSAccess using SQL. It
I'm having difficulty retrieving the giftcard code and amount used on an order. For

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.