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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:35:47+00:00 2026-05-16T18:35:47+00:00

So I have this list of ints. It could be a Vector , int[]

  • 0

So I have this “list” of ints. It could be a Vector, int[], List<Integer>, whatever.

My goal though is to sort the ints and end up with a String[]. How the int array starts out as is up in the air.

ex:
Start with:{5,1,2,11,3}
End with: String[] = {"1","2","3","5","11"}

Is there anyway to do this without a for loop? I have a for loop now for collecting the ints. I would rather skip doing another for loop.

  • 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-16T18:35:48+00:00Added an answer on May 16, 2026 at 6:35 pm
    int[] nums = {5,1,2,11,3}; //List or Vector
    Arrays.sort(nums); //Collections.sort() for List,Vector
    String a=Arrays.toString(nums); //toString the List or Vector
    String ar[]=a.substring(1,a.length()-1).split(", ");
    System.out.println(Arrays.toString(ar));
    

    UPDATE:

    A shorter version:

    int[] nums = {-5,1,2,11,3};
    Arrays.sort(nums);
    String[] a=Arrays.toString(nums).split("[\\[\\]]")[1].split(", "); 
    System.out.println(Arrays.toString(a));  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of ints and a list of objects which contain int
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I have this List<string> . How to get certain strings via LINQ? I guessed
I have this list of people with checkboxes next to their names. When you
We Have this : List<Person> listPerson ; Want to use the Data of listPerson
I have this list: mylist = [20, 30, 25, 20, 30] After getting the
If I have this list with 10 elements: >>> l = [1,2,3,4,5,6,7,8,9,0] Why will
Hello I have this list that i am working on. When i move the
Actually I have this list Directory where I am adding the name of the
I've been playing with Python and I have this list that I need worked

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.