Dana Horst

Ranch Hand
+ Follow
since Aug 13, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dana Horst

hello guys! here is the task i have :
A sandwich is two pieces of bread with something in between. Return the string that is between the first and last appearance of "bread" in the given string, or return the empty string "" if there are not two pieces of bread.

getSandwich("breadjambread") → "jam"
getSandwich("xxbreadjambreadyy") → "jam"
getSandwich("xxbreadyy") → ""

here is my code :


when code compiles, i get the melding :Exception:java.lang.StringIndexOutOfBoundsException: String index out of range: -5 (line number:16)" ( getSandwich("xxbreadyy") → "" " ).what i did wrong in a code, that this example didnt go via if (b == -1 || bsecond == -1 ){ return "";} statement? Thank you!
10 years ago
Hello guys!
here is the problem to solve : We'll say that a String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string. So "xxy" is balanced, but "xyx" is not. One 'y' can balance multiple 'x's. Return true if the given string is xy-balanced.

xyBalance("aaxbby") → true
xyBalance("aaxbb") → false
xyBalance("yaaxbb") → false

here is the working solution:



please answer the Qs, written in the comments within the code. Thank you!
10 years ago
Thank you both for the answers!
10 years ago
Thanks for reply Jesper. With putting conditions with length() == 0 || 1 i try to evoid error if String will be empty or with length 1. With line 10 I have a difficulty - dont know how to formulate the rule correct.
10 years ago
Hello guys!
here is the task i have to solve:
Given a string, compute recursively a new string where all the adjacent chars are now separated by a "*".

allStar("hello") → "h*e*l*l*o"
allStar("abc") → "a*b*c"
allStar("ab") → "a*b"

Here is my solution,which is not completed:



Please correct the code so it produces string witj * between every elements. Thank you!
10 years ago
Dear Steve,
when i run 2 codes the bin document ("data.bit") in Package view supposed to be generated, which can be opened with the text editor. I only get the "writing is done" in console.
10 years ago
Hello guys! I have two classes, which suppose generate the document "data.bin". i have tried to run the code in eclipse and sap netweaver dev studio, but havent got a desired result. what could be a problem? can anyone try to run those codes within yours ide? many thanks!

code 1:



code 2:

10 years ago

If you wan't to make a method that prints Student name just put firstName and lastName to System.out.println() in it. - it works, indeed:) thank you
Why your Student class has an instance variable Student?
An instance variable means "has a". So why your Student has a Student? - i use already created code, just need to add some method to let the full name display. variable Student was later used in a for loop, but i am not actually.


I think you use some IDE do learn Java. Don't do that. IDE makes lots of work instead of you.
It is nice to work with Java but it is not a good idea to use it for learning Java.
When something goes wrong you suddenly don't understand why...
Just use Notepad++ and compile from command line. It's fun :). - yes you are right, i use Eclipse. well, notepad++ just downloaded, thanks for a tip! and thanks for reply !
10 years ago
The code throws "Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error, insert "}" to complete Block at goodday.Main.main(Student.java:26)" . Before ecexuting, the code highlijghts 2 lines: System.out.println(s.printFullName()); and public class Main {.
10 years ago
Hello guys! here is the code :


supposed output is :

Morgan Freeman
Brad Pitt
Kevin Spacey

Question : how i can repair my mistakes? Thanks!
10 years ago
oh yeah, indeed. Thank you Manish
10 years ago
Hi guys, please help me to understand the code (i made my try to explain line by line, but not everything is clear)



Thanks!
10 years ago
yes, it helps! thank you xx
10 years ago
I run the code in Eclipse. run as - 1 Java Bean.
And yes, i am sure i run the right code. but still get this strange melding
10 years ago