Q:

Cannot compare Chars in java, code running but results don't come

/* Program to search a character in a sentence and tell the occurrence of 
that character in that sentence and also prints all the indexes. */

package com.shobhit.string1;
import java.util.Scanner;

public class StringSearch1
{
  public static void main(String args[])
  {
    String sentence;
    char c; // takes first character of input
    char duplicate; // finds duplicates of c in code
    int length; // find sentence length
    int index; // index of character in sentence
    int numberOfOccurrence = 0;
    Scanner in = new Scanner(System.in);

    System.out.println("Enter a sentence:");
    sentence = in.nextLine();

    System.out.println("Enter a character you want to find in the sentence:");
    c = in.next().charAt(0);
    length = sentence.length();

    System.out.println("The indexes of the character are:");
    for (int i = 0; i >= length - 1; i++)
    {
      duplicate = sentence.charAt(i);
      if (c == duplicate)
      {
        numberOfOccurrence = numberOfOccurrence + 1;
        index = sentence.indexOf(c);
        System.out.println("Index is:" + index);
      }
    }

    System.out.println("The number of times " + c + " has occured is:"
        + numberOfOccurrence);
  }
}

Unexpected output:
Enter a sentence:
 I don't want to type another long sentence
 Enter a character you want to find in the sentence:
t
The indexes of the character are:
The number of times t has occured is:0

A:

You want this look like this
for(int i = 0 ; i < length; i++)

instead of 
for(int i = 0 ; i >= length -1; i++)

because it is never going to be iterate for length > 1 cases

