Solved

word inside a tag challenge

Posted on 2014-11-10
2
177 Views
Last Modified: 2014-11-11
Hi,

I am trying below challenge
http://codingbat.com/prob/p184030

I wrote code as below

public String makeOutWord(String out, String word) {
  return out+word+out;
}

Open in new window



My test cases are failing

How to fix and improve my code. Please advise
0
Comment
Question by:gudii9
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40433992
Note: use str.substring(i, j) to extract the String starting at index i and going up to but not including index j.
0
 
LVL 7

Author Comment

by:gudii9
ID: 40434895
public String makeOutWord(String out, String word) {
  return out.substring(0,2)+word+out.substring(2,4);
}

Open in new window


i tried as below works good
Expected      Run            
makeOutWord("<<>>", "Yay") → "<<Yay>>"      "<<Yay>>"      OK         
makeOutWord("<<>>", "WooHoo") → "<<WooHoo>>"      "<<WooHoo>>"      OK         
makeOutWord("[[]]", "word") → "[[word]]"      "[[word]]"      OK         
makeOutWord("HHoo", "Hello") → "HHHellooo"      "HHHellooo"      OK         
makeOutWord("abyz", "YAY") → "abYAYyz"      "abYAYyz"      OK         
other tests
OK
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question