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

 
 


Nishant Jain
Some error find whats the problem
1 Answer(s)      2 years and 3 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

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 Pages:
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
Some Notes on Java Programming Environments
the javac compiler is an error. In some cases, it generates "warnings... Appendix 2: Some Notes on Java Programming Environments ANYONE WHO...-line environments. All programming environments for Java require some text
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
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
Sort the element find mean
Sort the element find mean  Hi Friend, I want to find meaning of some real numbers like, if we have numbers- 52.15, 89.0, 314.48, 845.75, 309.11, 575.36, 398.98, 318.64, 2485.12, 377.44 Then I want to find
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
runtime error
;Hi, This error is related to some OS related problem. "dsn contains an architecture mismatch between the driver and application" To solve this problem you...runtime error  still i am getting runtime error as:the specified dsn
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
problem - WebSevices
problem  i am using windows vista home basic.I installed tomcat6 succesfully and used the service for some application.But after restarting the machine i got an error message "unable to open the service tomcat6".how can i solve
Some additions for my previous question - Java Beginners
Some additions for my previous question  This is the question I... if the number is prime or not and also how to find the factors but I'm stuck... an invalid option, then the program should give an appropriate error message. I
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
Java Compilation error - JSP-Servlet
-fileupload-1.2.1.jar but still there is a problem and when i compile my file this error still come. pls can some one help to move out of this? thanks C:\pv>javac...Java Compilation error  hi i m vipul chauhan , i having a problem
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
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
Java Compilation and running error - RMI
some problem and gives following on compilation"java uses unchecked or unsafe...Java Compilation and running error   The following set of programs... showing problem. Please tell me why I am unable to run this program with Java
Error - Struts
create the url for that action then "Struts Problem Report Struts has detected... inform what is the problem here. Friends I am stuch with this. Please help me..., K.Senthuran.   Hi friend, Do some changes in code try
error in code - Java Server Faces Questions
error in code  hi friends i have a problem in execution of JSF it is displaying the error like "Cannot find FacesContext" i am not understanding plz... friend, Do some changes to remove the error in web.xml You changes
error in java progran at run time - Java Beginners
error in java progran at run time  Hello sir,,, i make a servlet program in java,,but i face some problem,,so please me.. Actually this type of error are come in my all servlet program My Servlet-- Error
error in java progran at run time - Java Beginners
error in java progran at run time  Hello sir,,, i make a servlet program in java,,but i face some problem,,so please me.. Actually this type of error are come in my all servlet program My Servlet-- Error
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???  
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
Logical error - Java Magazine
Logical error  hi guys... I am facing some probleam in do-while loop so plz check out my code and inform me whats wrong with this code thanks..... import java.io.*; class searchex { String str=new String
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
Need some help urgently
number of possible combinations.   The actual question got some error. Its...Need some help urgently  Can someone please help me with this below question. I need to write a class for this. If you roll Y standard six-sided dice
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
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 detection - Java Beginners
to repair the error but got stuck. please help me to find out what must i do to repair...error detection   Hi Amardeep and all friends out there could you pls tell me whats wrong with my codes shown down on this page, i tried
apache tomcat problem - JSP-Servlet
This environment variable is needed to run this program" error. CATALINA_HOME...\;"; i installed my apache tomcat in c: whats wrong with this  
JScript error - JSP-Servlet
to understand this because this error occurs in some logins only. Other logins did not show... project for my class. It has session concept.There are 57 possible logins. In some logins while updating profile it will not show any error. But, in many logins
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
mysql problem - JDBC
mysql problem   hai friends i have some problem with image... out of bound of size error. please provide the logic for storing normal maxi size... friends myself posted this question but i have refer some books and get some idea. i
Error In starting Glassfish in Eclipse.
Error In starting Glassfish in Eclipse.  Sir,I am new in Java/J2EE.And i am learning j2ee by regular study of your site. I am facing a problem... glassfish in eclise,an error is raised and message is as follws : "error Launching
Error in POI - Java Beginners
Error in POI  Hi friend, I am working with Excel using POI API.I need to read an excel file and do some modifications and save this file... workbook.removeSheetAt(index). This works fine without any exception. The problem now
some methods not working on firefox and chrome
some methods not working on firefox and chrome  why some of javascript methods are not working on firefox and chrome? ex : createElement(). Please help me to solve this problem. adv thanx
output error - JSP-Servlet
error? How can i solve this problem? */ HTTP Status 500... report message description The server encountered an internal error... javax.servlet.ServletException: Wrapper cannot find servlet class numbers or a class it depends
data type used to store name.(getting an error)
getting an error like dis: "ename cannot be resolved to a variable" whats the problem in my code and how to rectify it. plzz help n thanx in adv...data type used to store name.(getting an error)    Statement stm
plz Help me find the correct programs answers
) { System.out.println("Error:::" + e); } } }   For Bank Problem...plz Help me find the correct programs answers   Create a washing... at nitesh_loveguy@yahoo.co.in. Thanks........   For 3 problem package com; import
Compilatation problem - Java Beginners
Compilatation problem  Hi All, I had uninstalled Java1.5 and installed java1.4 for some reasons. Before i was able to compile and execute the code... the error like this : 'javac' is not recognized as an internal or external command
STRUTS 2 Could not find action or result
STRUTS 2 Could not find action or result  hiii..i am new to struts 2 framework...i developed my jsp code into sturs frame work...but its showing some... on my log: WARNING: Could not find action or result There is no Action
java error - Java Beginners
. But if I want to run that program the fetches me the following error. For example...(ClassLoader.java:316) Could not find the main class: Test. Program will exit. C:\Program Files\Java\jdk1.6.0_17\bin> what may be the possible problem
Java interval problem - Java Beginners
Java interval problem  I want to create a problem that finds the common interval of some periods of hours. For example if i have the time period: 10.00-12.00 and i have the time period: 11.00-13.00, i want to find the common
Servlet Problem proceed - JSP-Servlet
Servlet Problem proceed  Thank you fro your reply. But I couldnt find any serious error.Please see this. User is the package classes/User... examController /examController Please reply me if any error found
code problem - Java Beginners
there is some small error in it.I want you to correct it and also I want to print
Struts2 Validation Problem - Struts
friend, Please remember some points for solving : 1.Open the url in the browser having the example of handling the error in struts 2. http
code error - JSP-Servlet
is error in this progrm. ss function describe() { window.status... complaint   Hi friend, Do some changes in your code to solve the problem. 1)In "describe()" function write code "return true"; 2
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.