Good day, tell me how to draw a symbol from Char, for example, I want to
char x = '+'; char a = 1; char b = 3; System.out.println(a + x + b);
How to do that counted? It feels like something else is going on.
Good day, tell me how to draw a symbol from Char, for example, I want to
char x = '+'; char a = 1; char b = 3; System.out.println(a + x + b);
How to do that counted? It feels like something else is going on.
Like that:
static public int calculate(char op, int first, int second) { switch (op) { // ... case '+': return first + second; // ... } } // где-то там int first = 3; int second = 2; char operator = '+'; int result = calculate(operator, first, second); System.out.println(result);
So the character code '+' 43, here and get 47 in the answer.
To get a numeric value from a variable of type char:
char a = '1'; int int_a = Integer.parseInt(String.valueOf(a));
Source: https://ru.stackoverflow.com/questions/303478/
All Articles