Answer to Question #50302 in Java | JSP | JSF for faraaz

Question #50302
this is my assignment: write a method called remove that accepts one ArrayList<String> parameter and one char parameter.go through the ArrayList and remove any string that begins with the character in the second parameter . the method does not need to return any values. i have posted my solution down below but for some reason there is an error.

public class test
{
public void remove(ArrayList() arInput, char c)
{
for (int i = 0; i <= arInput.length; i++)
{
ArrayList() newArray = new ArrayList();
if (c != arInput[i].substring(0,1))
{
newArray.put[arInput[i]];
}
}
System.out.println("new array is: " + newArray);
}
}
1
Expert's answer
2015-01-08T01:18:39-0500
Solution.

public class test
{
public void remove(ArrayList<String> arInput, Stringc)
{
ArrayList<String> newArray = new ArrayList();
for(int i = 0; i <= arInput.size(); i++)
{
if(c != arInput.get(i).substring(0,1))
{
newArray.add(arInput.get(i));
}
}
System.out.println("new array is: " + newArray);
}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS