Need some help solving a code challenge (Camel to Snake) (Java)
I'm getting all of the trials correct except the fifth one (it won't let me know what it is) My code is below, I know it's messy I'm still pretty new to Java but I added some comments import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] camel = sc.nextLine().toCharArray(); // original input String fin = ""; // final string to be used int x = 0; // used to tell if the following code is the first instance or not for (char i:camel){ if (Character.isUpperCase(i) && x>0){ fin+="_"+Character.toLowerCase(i); } // adds _c for C to final if its uppercase and not the first time else { fin+=i; //adds original character }; x++; }; System.out.println(fin); } }