What is the output
public static Brainly {
public static void main )Strings [] args) {
int m = 4;
int lol = 10;
S.o.pln(m.replace(4,10) + lol);
}
}
Answers
Answered by
9
Corrected Code(after removing syntax errors):-
- public class Brainly {
- public static void main (Strings [] args) {
- int m = 4;
- int lol = 10;
- System.out.println(m.replace(4,10) + lol);
- }
- }
- Your code has some errors due to which it will not compile
What are the errors?
- Line no. 5, m.replace(4,10)
- m is integer and replace() is a string function
- replace() is used to replace a character/set of character with another character/set of character in a string.
Here is your Similar Code
public class Brainly {
public static void main (Strings [] args) {
String m = "4";
int lol = 10;
System.out.println(m.replace("4","10") + lol);
}
}
Note:- In this case, your output will be 1010 not 20
because, string gets concatenated .
Similar questions