Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
code that prints the scanned word, would want the program to print word where any occurrence of z is replaced with y

public class Char {

    public static void main(String[] args) {
        System.out.println("Please enter your words");
        Scanner scan = new Scanner(System.in);

        String word = scan.nextLine();

        for(char a : word.toCharArray())
        {            
            System.out.println(a);           
        }
    }
}


What I have tried:

changed code several times with different arguments
Posted
Updated 5-Feb-18 5:29am
Comments
Richard MacCutchan 5-Feb-18 11:27am    
What?

1 solution

There are many different nextXXX methods in the Scanner class. Choose one that most closely provides a solution to your problem: Scanner (Java Platform SE 7 )[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900