I am just a beginner in programming, but I have the following doubt: Is it possible to inject code in java through System.in? For example, I have this code:
import java.io.*;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Enter something");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String r = br.readLine();
System.out.println("You entered: " + r);
} catch (IOException ioe) {
}
}
}
Is it possible to, from example, in the input that is saved in String r, write a sum of two numbers and then the output shows you the sum of those two numbers instead of those two numbers and the sum character?
Like you enter
(some code and)
2+2
and it says
You entered 4