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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:10:08+00:00 2026-06-10T14:10:08+00:00

I was hoping someone could help me out with a small problem I am

  • 0

I was hoping someone could help me out with a small problem I am having in java. I have a List and an ArrayList that I would like to output to a file with the first element of each, printed next to one another. Here is what I have so far:

List<String> uniqueList = new ArrayList<String>(dupMap.values());
for(String unique:uniqueList){
   out.write(unique + "\r");
}
ArrayList<Integer>subtr=new ArrayList<Integer>();
out.write("The number: " + subtr + "\r");

This results in this output:

A
B
C
D
E
F
The number: [1, 2, 3, 4, 5, 6]

But I would rather it be like this:

A The number: 1
B The number: 2

…etc.

I am not really sure where to start on how to get the output format like that. I tried putting both sets of values into arrays but I just ended up confusing myself… Which is how I ended up here. Any help would be super appreciated.

  • 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-10T14:10:09+00:00Added an answer on June 10, 2026 at 2:10 pm

    Simply do this:

    String br = System.getProperty("line.separator");
    for (int i = 0, n = Math.min(uniqueList.size(), subtr.size()); i < n; i++)
        out.write(uniqueList.get(i) + " The number: " + subtr.get(i) + br);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was hoping someone could help me out with this stupid problem I'm having
I got a problem I was hoping someone could help me figure out! I
I am somewhat new to java and was hoping that someone could help me.
I was hoping someone could help me with a little issue I'm having trouble
I was hoping someone could help me figure out what to do about a
I'm struggling on some coding and was hoping someone could help me out please,
I'm new to rails and heroku and was hoping someone could help me out
I was hoping someone could help me figure out how to change the setmessage
I was hoping someone that is good with math and loops could help me
I'm having trouble with one particular issue, I was hoping someone could help me

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.