Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Why this inner loop is not working (https://www.askmehelpdesk.com/showthread.php?t=822373)

  • Mar 3, 2016, 10:09 AM
    rsingh
    Why this inner loop is not working
    public static void main(String arg[])
    {
    Scanner sc=new Scanner(System.in);
    String st="";
    int t;
    t=sc.nextInt();
    int count=0;
    st=sc.nextLine().toLowerCase();
    int a=st.length()-1;
    for(int r=0;r<t;r++){

    count=0;

    for(int i=0;i<a;i++)
    {
    if(st.charAt(I)==st.charAt(I+1))
    count++;
    }
    System.out.println(count);


    }

  • All times are GMT -7. The time now is 05:16 AM.