- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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.n
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
- Related Articles
- Java program to count upper and lower case characters in a given string
- C# program to count upper and lower case characters in a given string
- Converting to upper case in Java.
- Convert a C++ String to Upper Case
- Alternate Lower Upper String Sort in C++
- Python program to count upper and lower case characters without using inbuilt functions
- Count upper and lower case characters without using inbuilt functions in Python program
- How to convert a string into upper case using JavaScript?
- C++ Program to Generate a Sequence of N Characters for a Given Specific Case
- Convert characters of a string to opposite case in C++
- How to transform List string to upper case in Java?
- C program to convert upper case to lower and vice versa by using string concepts
- PHP – Make an upper case string using mb_strtoupper()
- How to check if a string contains only upper case letters in Python?
- C# Program to check a string for whitespace characters or null

Advertisements