Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Some error find whats the problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nishant Jain
Some error find whats the problem
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


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


Advertisement
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
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
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 error cannot find symbol
Whenever a Compiler does not recognize a class name, Java displays an error “cannot find symbol”. The reason behind cannot find symbol error... the java error cannot find symbol. In this example a class name 'cannot find
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"); }   Hi...("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
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???  
Java error cannot find symbol
Java error cannot find symbol       The java error cannot find symbol occurred when a Compiler...; the compiler does not recognize a variable e show you an error Java error cannot find
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
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 function computeGrade( ) { var hw, lab, midt, fin, avg; hw = parseFloat
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
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
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
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
whats the difference between struts and spring frameworks.why we use spring instead of struts
whats the difference between struts and spring frameworks.why we use spring instead of struts  whats the difference between struts and spring frameworks.why we use spring instead of struts
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
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
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
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
if i run this prog, i got exeption in thread "main" java.lang.ArrayIndexOutOfBoundsException:0 at Maxof2.main(Maxof2.java:9), whats the resolution for ths?
if i run this prog, i got exeption in thread "main" java.lang.ArrayIndexOutOfBoundsException:0 at Maxof2.main(Maxof2.java:9), whats the resolution for ths?  class Maxof2{ public static void main(String args[]){ //taking
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
error
error  while iam compiling iam getting expected error
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
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
Advertisements
 

 

 

DMCA.com