Given a string such as "123" or "67", write a function to output the number represented by the string without using casting.
Anonymous
Java Code public class StringToInt{ public static void main(String[] args){ String str = args[0]; int length = str.length(); length --; int num = 0; for(int i = length; i >= 0; i --){ num += (str.codePointAt(i) - 48) * Math.pow(10, length - i); } System.out.println(num); } }
Check out your Company Bowl for anonymous work chats.