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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:15:30+00:00 2026-06-15T14:15:30+00:00

I am attempting to get multiple String variables set with one println. Here is

  • 0

I am attempting to get multiple String variables set with one println. Here is what I have:

Scanner scanner = new Scanner(System.in);

String teacher = "";
String classSelect = "";
String location = "";

System.out.println("Enter a teacher: ");
teacher = scanner.next();

System.out.println("Enter a class name: ");
classSelect = scanner.next();

System.out.println("Enter a location: ");
location = scanner.next();

Here is what I would like to accomplish:

String section = "";
String instructor = "";
String location = "";

System.out.printf("Only fill in applicable criteria, leave the rest blank :\n"
        + "Section://Sets section var// \n"
        + "Instructor://Sets instructor var// \n"
        + "Location://Sets location var// \n");
  • 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-15T14:15:31+00:00Added an answer on June 15, 2026 at 2:15 pm

    This might not be an ethical way but try it

    System.out.printf("Only fill in applicable criteria, leave the rest blank and use | after every field:\n"
            + "Section://Sets section var// \n"
            + "Instructor://Sets instructor var// \n"
            + "Location://Sets location var// \n");
    

    if the user enteres

    abc|xyz|loc
    

    accept it in a string

    String input = scanner.nextLine();
    String[] inputs=input.split("|");
    inputs[0]//<--section
    inputs[1]//<--instructor
    inputs[2]//<--location
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Im attempting to get a block of text from a file I have already
I am attempting to get rails routes paths via nested resources. I have looked
I have been attempting to get log4net logging in my asp.net web application with
I'm attempting to implement a singly linked list to hold multiple String values in
I have multiple configurations set up in Visual Studio so that I can build
Similar to the question here , I am attempting to get the latest result
Im attempting to get some records from a table based on certain factors. One
I'm attempting to get rid of an app's HTML files and store their contents
I´ve been attempting to get a polar plotting in a PolarChart using MSchart, and

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.