Java Program to Count Vowels in a String

Опубликовано: 24 Июль 2026
на канале: CodeWithBK
436
5

Java Program to Count Vowels in a String

Welcome to CodeWithBK — your go-to hub for mastering Java programming.

Learn how to count the number of vowels in a string using Java with three different approaches – using if statements, indexOf() method, and switch-case. This beginner-friendly tutorial explains the logic step-by-step and demonstrates working Java code for all three methods.

In this video, you will:
Understand what vowels are and how to identify them in a string
Use the if statement approach to count vowels
Use the indexOf() method for checking vowels efficiently
Implement a switch-case approach for vowel counting
Work with char data type and string manipulation techniques
See complete Java code examples for all three methods

Code Link :

Perfect for:
B.Tech / BCA students
Java beginners
Coding interview prep
ICSE Class 10 Computer Applications students
ISC Computer Science Class 11 & Class 12 students
AP Computer Science students learning Java
Java Practice program in Strings & Loops

Programming Language: Java
Level: Beginner-friendly

Related Videos:
Count consonants in String:    • Java Program to Count Consonants in a String  
Validate a Password String :    • Java Program to Validate a Password  

Timestamps:
00:00 Introduction
00:26 Problem introduction
01:06 Solution explanation
02:45 Java code
05:43 Alternate method 1 - check if char is vowel using indexOf()
07:44 Alternate method 2 - check if char is vowel using switch-case
09:55 Optimisations
11:25 Running the code

🔔 Don’t forget to like, share, and subscribe to CodeWithBK for more such Java tutorials in simple language!

Stay connected:
Subscribe:    / @codewithbk  
Email: [email protected]
Discord:   / discord  

Coding mentor profile: https://www.codementor.io/@balkrishna...
For 1:1 sessions, reach out to me here : https://www.codementor.io/@balkrishna...

My YouTube channel where I teach in Hindi :    / @codewithbkhindi  

#JavaTutorial #JavaBeginners #CodeWithBK #JavaBeginners #JavaInterviewQuestions #JavaBasics #javatutorialforbeginners #javaprogrammingbasics #javaprogrammingforbeginners