Make Selenium Easy

Frequently Asked Java Program 11: Find Position Of Letter In Alphabet

Hello Folks,

As part of Frequently Asked Java Programs In Interviews For Freshers And Experienced, in this post we will see a Java program to Find Position Of Letter In Alphabet.


Accept a letter from user and print position of input letter in alphabet.

Example: A has 1st position in alphabet. B has 2nd position in alphabet.


  1. We will use ASCII concept here.
  2. Every letters in alphabet (both upper and lower case) has unique ASCII value.
  3. We can retrieve ASCII value of any char by casting in to int.


  1. Convert input letter in to uniform case either in upper case or lower. I will convert in to lower case.
  2. Convert char in to ASCII value using toLowerCase() method of Character wrapper class.
  3. ASCII value for lower case alphabet stars from 97.
  4. To get the position, subtract 96 from ASCII value of  input character. In case if you convert input letter in to upper case, you need to subtract 64 as ASCII value for upper case alphabet stars from 65.

Java Code:


If you have any other logic of solving above problem, please comment. It is always better to know more logic.

If you like my posts, please like, comment, share and subscribe.


Table of Contents

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

2 thoughts on “Frequently Asked Java Program 11: Find Position Of Letter In Alphabet

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

Frequently Asked Java Program 11: Find Position Of Letter In Alphabet

by Amod Mahajan time to read: 1 min
%d bloggers like this: