Solved

word inside a tag challenge

Posted on 2014-11-10
2
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

729 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