?
Solved

word inside a tag challenge

Posted on 2014-11-10
2
Medium Priority
?
186 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 2000 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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
A solution for Fortify Path Manipulation.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

777 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