Users Pricing

forum

Home Forums charAt() and substring method in java – MindStick

charAt() and substring method in java

Anonymous User 2554 10 Oct 2014
I want to go through each character in a String and pass each character of the String as a String to another function.
String s = "abcdefg";
for (int i = 0; i < s.length(); i++)
{
      newFunction(s.substring(i, i + 1));
}

or

String s = "abcdefg";
for (int i = 0; i < s.length(); i++)
{
       newFunction(Character.toString(s.charAt(i)));
}


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md