![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program for converting Alternate characters of a string to Upper Case.
You can convert a character to upper case using the toUpperCase() method of the character class.
Example
Following program converts alternate characters of a string to Upper Case.
import java.util.Scanner; public class UpperCase { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a string :"); String str = sc.nextLine(); str = str.toLowerCase(); char[] ch = str.toCharArray(); for(int i=0; i<ch.length; i=i+2){ ch[i] = Character.toUpperCase(ch[i]); } System.out.println(new String(ch)); } }
Output
Enter a string : hihowareyou HiHoWaReYoU
Advertisements