Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Stefan Brandenberger

Greenhorn
+ Follow
since Aug 31, 2009
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stefan Brandenberger

Neither, nor. You assign the return value to localNumber, don't you?

substring()'s return value type is String. The variable you assign this value to must therefore also be a String. D'accord?
12 years ago
Phone number (phoneNumber) as a string is quite ok. And the index (currentIndex) should indeed be an int.

The error lays elsewhere: Look at the return value of the String.substring(...)-method. The variable, you assign the return value to, should be of the same type.
12 years ago
Hi Ben

Well... without having the line-numbers, the error points to, it's much more difficult to find out...

But my guess are these lines (26, 28, 32, 34):



Check them again .

Stefan
12 years ago
Have a look at class System:



So "out" is a public static field of type PrintStream in the System-class. And with System.out.println() you invoke the method "println()" on this PrintStream-Object.
12 years ago
What do you mean by "that its indicators are string"? You want to access the array this way?

That won't work.

Maybe you should consider to use a List or a Map.
12 years ago
On line 5 of class Software you create a new Application with the parameterless Constructor. So in this instance, the Application-array apps holds 4 instances of Application, created in your loadApplications()-method. On line 7 you call getNextApplication() on it, which returns the first entry of the array. Note, that this Application was created with the second constructor (new Application("Aquatint","1.1","Stick Software","","Mike","crocodiles","http://www.sticksoftware.com/","","");). Therefore it's apps-array is empty, because you don't call loadApplications() in that constructor.

So app on line 10 is null. Bingo.

One mistake, you make, is to reuse the variable app again and again. That way you call getNextApplication() always on a new instance of Application. Try this:


...but don't try it more than 4 times .

By the way: what is the intention to hold a list of Applications in Application-class? Shouldn't it rather be a class ApplicationPortfolio or so, to hold the Applications?
12 years ago
Hi Mike

My guess is, that getNextApplication () always returns null. But to verify, I'd like to see the code of method loadApplications () that's called in the parameterless Constructor of Application.

Stefan
12 years ago

Donielle Locke-Bowen wrote:What's the syntax for printing Hashmaps? HELP!!!


Hi Donielle

would do that for you.

But thats not what you really want .

You build a Map with the found integers as key and the number of their occurences as value. So, when you're finished with building the map, you have to loop over it (hint: Map.entrySet()) and print those keys with an associated value > 1. But maybe your textbook has examples for that.

Further: Your Scanner takes a String as constructor-argument. So what you actually are scanning is the string "assignment.txt" and not the content of a file with that name. Fortunately there's also a constructor that takes an InputStream. So all you have to do is first create a FileInputStream on your "assignment.txt"-file.

Stefan
12 years ago
I cant' explain, I just tried out. So my answer ist: it won't compile. Because you do override the method of EEE but you don't implement the method of DDD. This will work:



No... I was wrong... doiIt is not == doIt ;-).

So, after a while, and another try I'd say: it doesn't matter. The method in EEE is implementing and extending. Because both d.doIt() and e.doIt() will execute the method in Test:



12 years ago

Carol Murphy wrote:Harry, are you sure that you have to work out how many times the name can be printed completely on each line? Or, rather, just write code that will print to the next line if the complete name doesn't fit?



Well, the latter can be evaluated by computing the former, no?
12 years ago

shan raj wrote:The code is



Expected output is "Is Hex String= true". But it says false and throws an NumberFormatException



Hi shan

If you want to do it that way, you have to check each digit, not the whole string at once.

Stefan
12 years ago
Hi Cristian

Maybe you mean something like the Appache Bean Utils? http://commons.apache.org/beanutils/

lets yout copy the properties from one to another bean.

Stefan
12 years ago