Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用string.replace()_Java - Fatal编程技术网

Java 使用string.replace()

Java 使用string.replace(),java,Java,我在某些编码中使用了string.replace,我不知道是否正确使用了它 例如: Scanner scan = new Scanner(System.in); System.out.println("Enter char to replace *:"); Sring wildcard = scan.scannextLine(); System.out.println("Enter name with wildcard."); String filename = s

我在某些编码中使用了string.replace,我不知道是否正确使用了它

例如:

   Scanner scan = new Scanner(System.in);
   System.out.println("Enter char to replace *:");
   Sring wildcard = scan.scannextLine();
   System.out.println("Enter name with wildcard.");
   String filename = scan.scannextLine();

   System.out.println(filename.replace(String "*", String wildcard));

这样说会给我一个错误或者“;”应在多个位置使用。请不要在字符串文字之前指定类字符串

filename.replace("*", wildcard)
nextLine是Scanner类中的现有方法。scannextLine不是


调用filename.repalce时指定类型;这是不需要的。乙二醇

System.out.println(filename.replace("*", wildcard));

声明通配符时字符串也拼写错误

请查看java语法。你觉得怎么样。替换字符串*。。。是否?filename.replace*,通配符。此外,s/Sring/String/。另外,java.util.Scanner没有scannextLine方法。@Marounnaroun作为一个java编译器,您甚至不能使用SIGSEGV!这是其中一个∞ 问题。@marounnmaroun我喜欢∞!@下一次我将为它制作动画。@marounnaroun,也许还有一个手绘圆圈围绕着它!请参阅我对@MartijnCourteaux的评论。注意,美丽∞ 那里
System.out.println(filename.replace("*", wildcard));