Ask Experts Questions for FREE Help !
Ask
    rsingh's Avatar
    rsingh Posts: 1, Reputation: 1
    New Member
     
    #1

    Mar 3, 2016, 10:09 AM
    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);


    }

Check out some similar questions!

Loop [ 1 Answers ]

I wrote two loops, my problem is if the program execute the first loop then the second it works fine. However, when it finishes from the second loop first time then to goes back to the first loop it will not get into the second loop again. it will iterate inside the first loop until the end. in...

Loop to zero values. [ 18 Answers ]

Hi all, I need a loop to zero values on sheets in my workbook. It will be best to have a look at the sheet attached, I will explain further. The sheets vary in length from day to day. For sheet "Emb" I need the columns "H" and "I" zeroed if grater than 0, starting at row 5 and is fixed at...

For loop [ 1 Answers ]

How would I design a For loop that displays the following set of 10, 20, 30, 40, 50,. 1,000?


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.