• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing two substrings

 
Dean WinchesterD
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys

I'm having this annoying problem with the substring method.

I use DataInputReader to read a raw binary file into a byte array.

Then I create a string from the array with: new String(myArray).

Now comes the weird part.

I cut two values from the String, lets say:



Then I add both string to an object:


And this object has an toString method where something goes wrong:



This method only prints the value of 'a' and ignores 'b'... But it works fine when I just return 'a' or 'b', so 'b' does have a value.

What could be the problem?

Regards
Dean
 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dean,

Is it return correct value when you run this code
 
Dean WinchesterD
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, they both print when tested separately.
 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your storing objects whole source code?
 
Dean WinchesterD
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The object is created here:



 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dean you have made a mistake in create methods line 31.

try these codes. compile and run.


I didn't made any change to AudioObjects code.
 
Dean WinchesterD
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic