I want to replace the occurrences of a character by another character but getting an error, not likely an error..the code runs but doesn't take input for second character to be inputted.
import java.io.*;
class replacement
{
public static void main(String args[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
String str=new String();
String str1=new String();
System.out.print("Enter a Text:");
str=in.readLine();
System.out.print("Enter the Character which you want to be Replace:");
a=(char)System.in.read();
System.out.print("Enter the character to be replaced:");
d=(char)System.in.read();
System.out.print("\nYour Text:"+str);
str.replace('a','d');
str1=str;
System.out.print("\nAfter Replacement:"+str1);
}
}
View Answers
July 6, 2012 at 8:47 PM
This is the output which i get.
Enter a Text:i am learning java
Enter the Character which you want to be Replace:a
Enter the character to be replaced:
Your Text:i am learning java
After Replacement:i am learning java
July 6, 2012 at 8:50 PM
Sorry,i forgot to write char during declaration of variables when writing this post.
Related Tutorials/Questions & Answers:
illeagal character error.... illeagal
character error.... Here is my
code:
import java.io....);
}
}
error:
MainScreen.java:19: illegal
character: \96
` Container container
Advertisements
Replace Character in String
Replace Character in String
... in a given
string.
To
replace a
character with the given
character in sting first... name for
replace) to be change with the new
character of the array. If any match
Java I/O Character Streams that facilitate to
take input
(read) the
character stream. Subclasses...Java
I/O
Character Streams
In this section we will discuss the
I/O
Character... and for this
Java provides the
Character stream
I/O.
Character stream
I/O
How to convert entity character to html characterHow to convert entity
character to html character Please help me to "convert entity
character to html
character" in java.
If possible please provide source
code which
take String as
input and return as String
Character class Character class
Character defines the forDigit();,digit()methods..how can these b used and wht does radix point signify here.i
want to knw what basically radix is??here in the arguments of these two???because
i tried runnin
underscore as characterunderscore as character how can
i consider _ as a
character instead of wildcard
character?
my problem is like this
i have 20 records as follows
manohar 1234455
manohar 453635
manohar 345454
manohar_1234455
now when
i am
Character ClassCharacter Class
Character defines the forDigit();,digit()methods..how can these b used and wht is radix point signifies here...in the arguments of these two???..pls answer a
code on this with radix .. are these methods also
find the first character is vowel or notfind the first
character is vowel or not hi friend, can u plz send me javascript
code for find the wether the first
character is a vowel or not. 2) check wether the last
character is same as the first
character or not
3) check
Unknown Character set: 'utf8mb4'.Unknown
Character set: 'utf8mb4'. While working on eclipse on an application that uses MySQL as the back end for the database,
I was having
error connecting with the database through JDBC,
when
i try to run the application
J2ME count character into stringJ2ME count
character into string
i am new in J2ME, my problem is how to count
character into number,
i had been research google for almost 2 days... form which allow user to
input character
user
input helloworld then press
php remove last characterphp remove last character to remove the last
character,
i used the trim function which is not working
Determining the type of Character determines if the specified
character is a
Unicode space
character.
Here is the
code...Determining the type of
Character
In this section, you will learn how to determine the type of a
character.
You can use the methods of
Character class
JavaScript regex validate Character character value :
<
input type="text" name="name" id="name" />
<
input type...
Character.
<html>
<head>
<title>
Character validation...
Character value : "+name);
return true;
}
alert
JavaScript regex validate Character character value :
<
input type="text" name="name" id="name" />
<
input type...
Character
<html>
<head>
<title>
Character validation...
Character value : "+name);
return true;
}
alert
Java get middle characterJava get middle
character
In this tutorial, you will learn how to get middle
character from the word.
Here is an example of
getting the middle letter...' and you
want to get the
character 'p' from the word, then you can
character literal in octal format;>>
EscapeSequence1.java:6:
error: unclosed
character literal
char...
^
EscapeSequence1.java:6:
error: unclosed
character literal
char ch2...
character literal in octal format class EscapeSequence1
{
public
How to sort chinese character in j2me?How to sort chinese
character in j2me? Hi All,
I want to sort chinese
character in j2me.
Please let me know whether it is achievable or not in j2me?
If Yes,Please help me by providing some sample
code snuippet for sorting
Character Wrapper Class.Character Wrapper Class. what are Mirrored Unicode Characters??
and whats the use of "isMirrored(ch);method ??.where ch is any
character argument.... There are special characters in UNICODE to achieve the RTL. Such
character is the Mirroring
character as command line argumentscharacter as command line arguments public class testing
{
public static void main(String args[])
{
char a;
a=args[0];
System.out.println("
character is:"+a);
}
}
what will be the above program output
Wrapper Character class. character. A
character is considered to be an ISO control
character if its
code...Wrapper
Character class. How do the methods 'isIndentifierIgnorable(ch)' and 'isISOControl(ch)' work?? while workin with '
Character' wrapper class
Alphabet Character Case-Converter converted lowercase
character.
Here is the
code of this program... Alphabet
Character Case-Converter
... a
character
(uppercase) into a lowercase
character. The java.lang package
provides
What is Character FunctionsWhat is
Character Functions What is
Character Functions
Hi,
Here is the answer,ADS_TO_REPLACE_1
Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST
Character Directions in javaCharacter Directions in java java 2,version 1.4 adds a method "getDirectionality();" , what is the use of this method ?
This method returns the Unicode directionality property for the given
character.
Character Count the character in javaCount the
character in java Write a java program to count the
character ââ?¬Ë?aââ?¬â?¢ typed by the user in a paragraph by implementing thread...(String[] args) throws Exception{
Scanner
input=new Scanner(System.in
Character count by while loopCharacter count by while loop Write the program to count the number...];
int count=0;
for ( int
i=0; i<third.length;
i++){
if (ch==third[
i...])
flag=true;
}
if(!flag){
System.out.println("
Character :"+ch+" occurs "+count
character counter - Java Beginnerscharacter counter how to show only first three characters...!!");
}
else{
System.out.println("First Three
Character is:"+c[0]+c[1]+c[2... void main(String args[])
{
new counter();
}
}
this
code count the repeated character in one stringcount the repeated
character in one string to find the how
character... 'a 'was repeated )
Hi Friend,
Try the following
code:
import... Exception{
Scanner
input=new Scanner(System.in);
System.out.print("Please
Character encoding problem with chinese languageCharacter encoding problem with chinese language
I have a issue with characters in chinese locale in java.
Iam using eclipse IDE
My
code...(stdDate);"
But iam
getting month name as '??'
Can anyone help me to solve
Get Character
Get
Character
In this example given below, we will learn how to read
character from keyboard
and display on standard output device. Method System.in.read() read
character Convert Character into Integer the
character data into an integer type.
Description of
code:ADS_TO_REPLACE_1... Convert
Character into Integer
In this section, you will learn to convert the
character word and character counting - Java Beginnersword and
character counting here is the java
code i made but
i have to add something where it will read the inFile and display the number of words...)
{
JOptionPane.showMessageDialog(null, "
Error:" + x1);
System.exit(0
getting error in your login form codegetting error in your login form code
i tried your
code for login form but
i am
getting an error.the
error is undefined index userid and password.the
code is $fuser=$POST["userid"];. how to solve this problem please help me
Get Character from String
Get
Character from String
... of
character and retrieve elements from that
character array one by
one.
Description of the
code:
1. First declare and initialize string.
2. use method
javascript regex validate Special character >
Enter Zip
Code :
<
input type="text" name="zip" id="zip" />
<
input...javascript regex validate Special
character javascript regex validate Special
character
<html>
<head>
<title>Zip
Check character in upper case or not.Description:
This tutorial demonstrate the use of Character.isUpperCase() method for
rectifying whether the value stored in char is in uppercase or not.
Code:
public class CheckUpper {