Some error find whats the problem

Some error find whats the problem

import java.io.*; public class Replace { public void main()throwsIoException { InputStreamReader = new InputStreamReader(System.in); BufferReader br=new BufferReader(z); System.out.println("Enter A String:"); String s=br.readline(); System.out.println(("Enter First Word:"); String w1=br.readline(); System.out.println("Enter Second Word:"); String w2=br.readline(); String str=" "; String st=" "; for(int i=0;i<=s.lenth();i++); { char ch=s.charAt(i); if(ch!=' ') { str=str+ch; { if(str.equals(w1)) { st=s.replace(w1,w2); } System.out.println(st); } } } output of above code Enter A String This is a flower Enter First Word is Enter Second Word was after replace string will be This was a flower note:- The word 'is' is existing in string so it's replace with second word 'was'.

Respected sir i've a problem with above code i unable to understand that what's the problem in above code because output is not so rightly so plz help me and follow these instruction 1 do not use Stringtokenizer 2 do not use reverse method 3 do not use StringBufferReader 4 do not use Split method

View Answers

February 26, 2011 at 2:51 PM

Java replace string

import java.io.*;
public class Replace{
    public static void main(String[]args) throws IOException { 
        InputStreamReader z= new InputStreamReader(System.in); 
        BufferedReader br=new BufferedReader(z);
        System.out.println("Enter A String:"); 
        String s=br.readLine(); 
        System.out.println("Enter First Word:");
        String w1=br.readLine();
        System.out.println("Enter Second Word:"); 
        String w2=br.readLine(); 
        String rep=s.replace(w1,w2);
        System.out.println("Replaced String: "+rep);
    }
}









Related Tutorials/Questions & Answers:
Some error find whats the problem
Some error find whats the problem  import java.io.*; public class... it's replace with second word 'was'. Respected sir i've a problem with above code i unable to understand that what's the problem in above code because output
I face some problem - Java Beginners
I face some problem  I face some problem in my project plz deepak halp me how can i solve this problem i m using bean and jsp file also... encountered an internal error () that prevented it from fulfilling this request
Advertisements
ModuleNotFoundError: No module named 'whats'
ModuleNotFoundError: No module named 'whats'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'whats..., ModuleNotFoundError: No module named 'whats' error will be solved. Thanks
ModuleNotFoundError: No module named 'whats'
ModuleNotFoundError: No module named 'whats'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'whats..., ModuleNotFoundError: No module named 'whats' error will be solved. Thanks
Error: Cannot find module 'jasmine-core'
Error: Cannot find module 'jasmine-core'  Hi, I am trying to make...: karma start Its throwing following error: Error: Cannot find module 'jasmine...; ^ Error: Cannot find module 'jasmine-core' at Function.Module.
Error 500: WSWS3142E: Error: Could not find Web services engine. - WebSevices
Error Could not find Web services engine   Hi...: faultNode: faultDetail: {}:return code: 500 Error 500: WSWS3142E: Error: Could not find Web services engine. { http://xml.apache.org/axis
Error 500: WSWS3142E: Error: Could not find Web services engine. - WebSevices
Error 500 WSWS3142E Error Could not find Web services engine  Hi all, I am getting the following error.Error 500: WSWS3142E: Error: Could not find Web services engine. Please Help. Thanks in Advance
could not find the main class programm will exit - error
could not find the main class programm will exit - error  when i tried to run the below mentioned programmed it gives a error states - could not find main class programm will exit. class Car { String name: String Color
JSP cannot find symbol error - JSP-Servlet
JSP cannot find symbol error  Suppose-- we created 'a.jsp' in which we make a database connection... how to retrieve 'new' here... If I want to access the 'new' string within the form what should i do???  
i cant find any compile time error but there is runtime error.
i cant find any compile time error but there is runtime error.  ...){ System.out.println("Error:connection not created"); } ADS_TO_REPLACE_1...){ System.out.println("Error is:" + s.getMessage()); } } catch (Exception e
Error !!! Can not find the tag library descriptor for "/WEB-INF/tlds/template.tld"
Error !!! Can not find the tag library descriptor for "/WEB-INF/tlds/template.tld"   I am not able to fix this problem. I tried different jar files, but no luck. Is there anything else apart from adding jar files that i can try
Java error cannot find symbol
“cannot find symbol”. The reason behind cannot find symbol error... the java error cannot find symbol. In this example a class name 'cannot find... “Java error cannot find symbol”.ADS_TO_REPLACE_2
Java error cannot find symbol
Java error cannot find symbol       The java error cannot find symbol... error cannot made symbol. For this we have a class name 'cannot find symbol
cannot find java.exe error while opening netbean5.5 - IDE Questions
cannot find java.exe error while opening netbean5.5  HI, 1)i am working netbean5.5 tool.I got the error of cannot find c:\programfiles\java... this problem? 2)while i am installing nokiamobiletoolkit, I got the error name
Java Compilation error. Hibernate code problem. Struts first example - Hibernate
Java Compilation error. Hibernate code problem. Struts first example  Java Compilation error. Hibernate code problem. Struts first example
ModuleNotFoundError: No module named 'whats_my_name'
'whats_my_name' error? Thanks   Hi, In your python...;whats_my_name' error will be solved. Thanks...ModuleNotFoundError: No module named 'whats_my_name'  Hi, My
ModuleNotFoundError: No module named 'whats-my-name-jx'
named 'whats-my-name-jx' error? Thanks   Hi, In your...: No module named 'whats-my-name-jx' error will be solved. Thanks...ModuleNotFoundError: No module named 'whats-my-name-jx'  Hi, My
Error 500-Server are not find the jar file in the program of upload the file - JSP-Servlet
Error 500-Server are not find the jar file in the program of upload the file  Hello Sir, your response: Hi friend, The 500 Internal Server Error is a "server-side" error, meaning the problem is not with your PC or Internet
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?  run: java.lang.NoClassDefFoundError: filecopy...) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main
Error : javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Error : javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope  I am getting following error in my struts-jsp proram for adding data to the database. 500 Internal Server Error
plz check my codings are correct or not...There is an error..i cant find it..
plz check my codings are correct or not...There is an error..i cant find it..  import java.util.Scanner; public class Student { private String indexNo; private String gender; private char initial; private int mark1
Problem In applet Its run on browser but hang and blinking when image is draging some where.
Problem In applet Its run on browser but hang and blinking when image is draging some where.  I am Created applet in working properly on browser. In my applet 52 card images is draw and drage and move on the applet, but when I am
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException
Java error cannot find symbol
Java error cannot find symbol In this section you will learn about "cannot find symbol" in java. Java cannot find symbol is a type of error occurs... the variable in use its trying to refer, then it will give a error cannot find symbol
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades ADS_TO_REPLACE_1 function computeGrade( ) { var hw, lab, midt, fin, avg; hw
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
"+it); } } this is my program i am getting an error saying cannot find symbol class stringADS
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version.ADS_TO_REPLACE_1 This type error also comes
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Problem with loginbean.jsp
Problem with loginbean.jsp  http://www.roseindia.net/jsp/loginbean.shtml - I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this? Also in this example how
problem with package
in " net" folder.The problem is i want to use that .class file in some other project.well i created the object and set the class_path but still it showing error...problem with package  Dear sir, i have created one java file
Tomcat Error:
Tomcat Error:   Hi, I am not able to start the tomcat server. If I try to start it then I am getting the below error. "coyote connector has not been started" Could some body please help me to solve the problem??? Thanks a ton

Ads