JAVA Problem
Write a program that takes two parameters
1. a word
2. an array of words
It should then remove all instances of the word in the array.
For Example:
INPUT
word="ravi"
word_array = ["Chethan Bhagat", "Ravi Beligere", "Ravana Kumar", "Megnath Ravichandran", "Superraviman guy"....]
OUTPUT
["Chethan Bhagat", " Beligere", "Ravana Kumar", "Megnath chandran", "Superman guy"....]
NOTE
- Do not use any string functions, except for string length
- Ignore case
- handle boundary conditions
- Optimize the code
View Answers
August 23, 2012 at 3:14 PM
The given code accepts a word and array of five words which then remove the occurrence of word in those array elements.
import java.util.*;
class RemoveFromArray
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter word: ");
String word=input.nextLine().toLowerCase();
System.out.println("Input array of words: ");
String array[]=new String[5];
String newarray[]=new String[5];
for(int i=0;i<array.length;i++){
array[i]=input.nextLine().toLowerCase();
}
System.out.println("Output array of words: ");
for(int i=0;i<newarray.length;i++){
newarray[i]=array[i].replaceAll(word,"").trim();
System.out.println(newarray[i]);
}
}
}
Ads
Related Tutorials/Questions & Answers:
java Problem
java Problem I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me.
Thanks in advance
JAVA Problem
JAVA Problem Write a program that takes two parameters
1. a word
2. an array of words
It should then remove all instances of the word in the array.
For Example:
INPUT
word="ravi"
word_array = ["Chethan Bhagat
Advertisements
resolution problem in java
resolution
problem in java I designed project in
java in my PC when run the same project in some other PC i can't fully view my
java forms.Some said that it is resolution
problem
Problem in uploading java application
Problem in uploading
java application I have uploaded my
java application (folder created under webapps) using Filezilla FtpClient.Application... this
problem
for a problem in coading - Java Beginners
for a
problem in coading what is the problm in following coading...(String[] args)
{
mywindow ();
}
}
Hi Friend,
There is no
problem... mywindows.java
Run :
java mywindows
Thanks
RoseIndia Team
java problem - Java Beginners
java problem Write a program that could be used to help children...();
System.out.print("How many problems would you like? ");
double
q = scan.nextDouble();
System.out.println();
double r=0,w=0;
for (int idx = 1; idx <=
q
Problem on JAVA Programme
Problem on
JAVA Programme public class AA {
int add(int i) {
int y = i;
y += 20;
if (y <= 100){ y +=30;add(y);}
System.out.println("Final Value of y : " + y);
return y;
}
public static void main
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM hi all Friends
I am stuck using the
java servlets and
problem raise for classpath.
I had a
problem with servlet to call... that it didn't found any
java class (which is
java class calling from servlet).
but i
Java implementation problem
/answers/viewqa/
Java-Beginners/28578-java-implementation-
problem-.html...
Java implementation problem I want to implement following in
java...
problem in your post previews.
please consider
1. 2. points just after main
java implementation problem
java implementation
problem I want to implement following in
java code :
Main thread
Create three threads
wait for completion of stage 2 of all three threads
Access all three local variable (LC0, LC1, LC2) of threads
bulid
Basic problem for Java experts
Basic
problem for
Java experts This assignment will test your knowledge of
Arrays
Array searching
Array sorting
Array processing
Specification
An athletics club require a simple statistical analysis program for analysing lap
Java program problem
Java program problem Hi,
I took the chance to login here in your educational page due to my questions in mind about my
java programming assignment... is a path to a directory.
Example:
java DuplicateFinder c:\Documents
java sms problem
java sms problem i am developing web site in which i have to maintain sms system where one can message his/her detail and it should be stored in the database.please give me some idea how to maintain it as i am beginner.Thank you
java array problem
java array problem suppose i have an array a[] at a[0] i have value 5,7
the thing is that i want to assign the value of array a[0]=5,7
to two variable let it be j,k
that is j=5 and k=7
plz help
regards
Java I/O problem
Java I/O problem
Write a
Java application that prompts the user to input their Name, Address, Date of Birth and Student ID number using the standard input - this information should then be saved to a file named studentData
java core basic problem
java core basic problem my question is:
write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class
Q impliments P12 Instantiate
Q and invoke each of its methods.Each
Java IF statement problem
Java IF statement problem Dear Sir/Madam
i am using the following code. expected to not have any output but it still showing "welcome".. please help me why it showing "welcome".
class c1
{
int a=5;
while(a>1
java core basic problem
java core basic problem my question is:
write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class
Q impliments P12 Instantiate
Q and invoke each of its methods.Each
Java code problem
Java code problem Please check the errors,if any,in this code...i am a
java beginner
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map
java textfield problem
java textfield problem I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here is the code
Java HashSet Collection problem
Java HashSet Collection problem Here's how the HashSet works. It maintains an array of buckets. When an object is inserted, it finds the appropriate bucket corresponding to the objects HashCode. Then it calls the equals method
Java Web Browser Problem
Java Web Browser Problem Hello
When run my web browser this is not displaying complete page any of the website like other browser.So Plz help me.
package vision.sun;
import java.awt.Container;
import
Java Servlet Problem - JSP-Servlet
Java Servlet Problem I have a servlet class that implemets... method. Please help!! Hi friend,
Please explain
problem in details for complete solution and send code the
where are you
problem.
Thanks
can interface solve this problem in java
can interface solve this
problem in java I have a JDialog which... this calander class. can interface solve this
problem. If yes then how. pls.../tutorial/
java/swing/datePicker.html
thanks very much
java servlet connectivity problem with access
java servlet connectivity
problem with access Import java.sql
javax.servlet
//all packages entered
try {
Class.forName...=con.createStatement();
^
i am confused what is the
problem
problem in reading 10000 records in java
problem in reading 10000 records in java Hi
I have a huge records 10000 records ,while reading it show some error only i can able to read 2000 recds and need to display all the recods in jsper reports
Thanks
Gopi
Problem with Java Source Code - Java Beginners
Problem with
Java Source Code Dear Sir I have Following Source Code ,But There is
Problem with classes,
plz Help Me.
package mes.gui;
import javax.swing.JOptionPane.*;
import java.sql.*;
import javax.swing.*;
import