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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:14:44+00:00 2026-06-10T12:14:44+00:00

In Java, is there a premade method that I can use to take some

  • 0

In Java, is there a premade method that I can use to take some selected indices of an array of chars, stick the terms defined by those indices together and return it as a string? The reason I’m looking for a method here is that I would like to avoid having to create another array to hold my selected values. What I’m looking for is something that looks like this:

public String charArrayToString(char[] array, int startingIndex, int lastIndex) {
        // ignore any index that is outside of the startingIndex - lastIndex range
        // turn array[startingIndex], array[startingIndex + 1] ... array[lastIndex] into a string
}
  • 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-10T12:14:46+00:00Added an answer on June 10, 2026 at 12:14 pm

    I would use the constructor

    public String charArrayToString(char[] array, int startingIndex, int lastIndex) {
        return new String(array, startIndex, lastIndex - startIndex + 1);
    }
    

    Depending on what you are doing with the result, a better solution might be to use StringBuilder.append

    char[] coords = "000175001022".toCharArray();
    
    StringBuilder sb = new StringBuilder();
    sb.append("( ");
    sb.append(coords, 0, 6);
    sb.append(", ");
    sb.append(coords, 6, 6);
    sb.append(" )");
    System.out.println(sb); // prints ( 000175, 001022 )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there Java class or some sample code that can convert a java Date
Is there java utility that does clone() method for HashMap such that it does
I know that in java there's two method of packaging one application. One way
Can anyone tell me how to use Xstream in Blackberry . In java there
I have read a document that they say: In java there two types of
Possible Duplicate: Java : Is there a good natural language processing library Can anybody
In Java there are a bunch of methods that all have to do with
I am very curious that whether in Java there is any way to release
I use Eclipse for Java development. There is an *.exe file in a subdirectory
Using Java is there anyway to display a custom form/image that behaves similar to

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.