Can you help please. It seems easy, but in general there are no ideas.

Пример: аргумент: “CAFE” результат: 51966 
  • one
    And how would you do it manually? Here is exactly the same algorithm and one could at least try to implement. - Enikeyschik

2 answers 2

To do this, simply use the parseInt method built into the Integer class.

 int number = Integer.parseInt("CAFE", 16); System.out.println(number); //51966 

if the number falls quite large, that is, a class that accepts integers of arbitrary dimension

 BigInteger big = new BigInteger("Thequickbrownfoxjumpsoverthelazydog", 36); System.out.println(big); // 2420279590275804445606588463955072096420804747701564608 

but this is no longer a primitive type and another story

     Long.parseLong("CAFE", 16); 

    I do not recommend using Integer, sometimes I get too large numbers.