Friday, 11 March 2016

Java Tutorial : Java String (lastIndexOf(int ch) method)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=1BHuIX4kv1w&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java String (lastIndexOf(int ch) method) 
LastIndexOfDemo.java
/*
 * public int lastIndexOf(int ch)
 * 
 * Parameters: 
 * ----------  
 * ch - a character (Unicode code point).
 *  
 * Returns: 
 * ------- 
 * Returns the index within this string of the last 
 * occurrence of the specified character. , or -1 if
 * the character does not occur.
 */

public class LastIndexOfDemo
{

    public static void main(String[] args)
    {
        String str = "Welcome";

        int indexPosition = str.lastIndexOf('e');
        System.out.println("lastIndexOf(\'e\') = " + indexPosition);

        // Unicode value of m is 109.
        indexPosition = str.lastIndexOf(109);
        System.out.println("lastIndexOf(\'m\') = " + indexPosition);

        indexPosition = str.lastIndexOf('a');
        System.out.println("lastIndexOf(\'a\') = " + indexPosition);

    }
}
Output
lastIndexOf('e') = 6
lastIndexOf('m') = 5
lastIndexOf('a') = -1
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringDemo_LastIndexOf_Int_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_LastIndexOf_Int_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/dd11550cc5ffaba129bb5f9efdfd0a5ae76620ca/BasicJava/StringDemo_LastIndexOf_Int_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge