0

What's the problem?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner hello = new Scanner (System.in); String words = caps (hello.nextLine()); System.out.println (words); } public static String caps (String x){ return x.toUpperCase; } }

13th Apr 2020, 6:05 PM
Yahel
Yahel - avatar
7 Answers
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scan = new Scanner (System.in); String x = scan.nextLine(); x = x.toUpperCase(); System.out.println (x); } } Correct one.
13th Apr 2020, 6:17 PM
C ++
C ++ - avatar
+ 1
toUpperCase It is a method not a keyword. There should be pranthesis after this. x.toUpperCase(); Note:. () yahel
13th Apr 2020, 6:37 PM
C ++
C ++ - avatar
+ 1
C ++ thanks !!
13th Apr 2020, 6:38 PM
Yahel
Yahel - avatar
0
// return x.toUpperCase; x = x.toUpperCase(); (...after this answer code in question was changed )
13th Apr 2020, 6:11 PM
zemiak
0
We can't return from a method having void return type. And the other thing., program stop executing the block of code in which return encountered at that line. Therefore, in this just convert string to uppercase.
13th Apr 2020, 6:13 PM
C ++
C ++ - avatar
0
I edited the post. What's the problem now?
13th Apr 2020, 6:17 PM
Yahel
Yahel - avatar
0
I tried another way...
13th Apr 2020, 6:17 PM
Yahel
Yahel - avatar