Hello everyone im new to Java and i need help in my code
/**
* @(#)Changing.java
*
*
* @author
* @version 1.00 2015/2/27
*/
import java.util.Random;
public class Changing {
public static void main(String[] args) {
Random generator = new Random();
int num1;
String phrase = "This is a pencil";
int len = phrase.length();
num1 = generator.nextInt(len);
char c = phrase.charAt(num1, 'x');
String mut1 = phrase.replace(c, 'x');
System.out.println(mut1);
}
}
I need to make progrom to pick a random letter and change it to X
Thank you
Aucun commentaire:
Enregistrer un commentaire