Write a program to accept a sample string and replace the word blue with red .
Answers
Answered by
6
Answer:
Heya user ,
Here is your answer !!
______________________
import java.util.*;
public class Words
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.print ( " Enter a sentence : " ) ;
String S = in.nextLine() ;
S = S.trim();
EXPLANATION :
☆ S is the actual string .
☆ Now , we trim the string so that all the extra spaces at the beginning and at the end are removed .
☆ The ' for ' loop count the number of blank spaces in the string .
☆ The no. of blank spaces is stored in the variable k .
Similar questions
Chemistry,
4 months ago
Accountancy,
4 months ago
Science,
9 months ago
Geography,
1 year ago
History,
1 year ago