3

So, I currently have a char array of 2000 chars. I will have 24 or less chars in the middle of this array that I need turned into a string. I have no ideas how to do this after many logic combinations and Google searches. Any help is appreciated!

2
  • 2
    have you written any code yet on this or just trying to get idea.? Commented Feb 4, 2015 at 5:11
  • A lot of code and a lot of failures that I deleted. I can recreate some of what I deleted. Commented Feb 4, 2015 at 5:14

2 Answers 2

4

String provides a constructor designed specifically for this task:

char[] bigData = ...
int startIndex = ...
int len = ...
String res = new String(bigData, startIndex, length);

startIndex represents the position in the array of characters where your string should begin; len represents the number of characters to take.

Sign up to request clarification or add additional context in comments.

Comments

2

try this constructor

String(char[] value, int offset, int count)

2 Comments

Can you explain what is meant o be plugged into the offset and count
If char[] a = {'a','b','c','d'} then new String(a,1,2) will make "bc"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.