I need to take a String, and print each character of it on a seperate line.
I would use a for loop right?
public String toString(){
for (int count=0; count < password.length(); count++)
{
System.out.print(password.charAt(count));
System.out.print("\n");
}
return password; // I am confused on this. I don't want it to
//return anything, really but I cannot make return type void
}
Is what I have, but I keep getting NullPointExceptions. I have a method above that stores the password from the input, and the variable is defined in the class. So, I figured it would pull it from that.
My Question is: How would I take a string and print each character from it, one on each line?
This would do the job: