Import java. util. arrays;/*** Plus One ** Given a number represented as an array of digits, plus one to the number. */public class S66 {public static void main (String [] args) {int [] digits = {9, 9}; // int [] digits = {0 }; system. out. println (Arrays. toString (plusOne (digits);} public static int [] plusOne (int [] digits) {int I = digits. length-1; int overflow = 0; // used to indicate whether overflow exists. // Add while (I> = 0) from the end to the end) {if (digits [I] + 1> 9) {// digits [I] = 0; overflow = 1; I --;} else {// when the number is less than 10, digits [I] = digits [I] + 1; return digits ;}// in this case, the current number of digits is insufficient, you must open a new array, // process the first if (overflow> 0) {int [] newDigits = new int [digits. length + 1]; System. arraycopy (digits, 0, newDigits, 1, digits. length); newDigits [0] = 1; newDigits [1] = 0; return newDigits;} return digits ;}}