Carey Brown

Saloon Keeper
+ Follow
since Nov 19, 2001
Merit badge: grant badges
Forum Moderator
Carey Brown currently moderates these forums:
For More
Colorado, USA
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Carey Brown

Barry's Boothang wrote: I've been working with a template for the project that has 4 files that just list data should I still take this approach?

Keeping the data in four separate files has some of the same issues as keeping them in four separate arrays: what if the file entries get out of sync? In situations like yours a typical file structure to store a list of some object type (e.g. IceCream) would be using comma separated values (CSV). Each row would represent a single object and each column would represent an attribute of that object. For IceCream it would look like:
To load it into an array of IceCream objects you'd loop through the lines in the CSV file and for each line use String[] data = line.split( "," ); to break out the individual columns and build an IceCream object.
1 day ago
First off having four lists to maintain in sync is not the Object Oriented way to do things. Create an IceCream class with 4 member variables and then just have a single list  of IceCream objects.
Secondly, Color, Availability, and Review have a fixed set of options and so should be implemented as enums.
Here is an example also showing an implementation of equals() that will only match on the selected fields.
2 days ago
This is not a beginner Java topic. What is Kafka?

I hope this is not like the last thread you started, posting a vague problem, and when someone was kind enough to respond you didn't respond back.
1 week ago
Show us what you've done so far and tell us where you're stuck.
1 week ago
If you join your else-if's together you reduce some of your indentation.
2 weeks ago
Your code is inconsistently indented making it difficult to follow. This is how it should look:
2 weeks ago
You are attempting to compare Strings using '==' which only compares the references. You need to be using the 'equals()' method instead which compares the characters.
2 weeks ago
In your case the cast only applies to 'fruit' and then the addition takes place. If you want to return 'long' use this:

Also, you should (almost) never use 'float', use double instead as it is almost always more efficient. 'float' is mainly used when trying to interface with legacy code that requires it.
2 weeks ago

Steve Dyke wrote:Sorry.
I was doing this:

Instead of this:


"replaceAll()" conflicts with the "$" meta-character which means match at end of string.
2 weeks ago

Steve Dyke wrote:Any character in the string that has a preceding space, I need to remove it.


Remove all instances of a space followed by a non-space.
2 weeks ago

Carey Brown wrote:

2 weeks ago

Campbell Ritchie wrote:What's wrong with substring()?


It's not conditional.
2 weeks ago

Steve Dyke wrote:I need it to return this:

System.out.println( trimPartNo( "41131001-299" ) );//Take out the "S"
System.out.println( trimPartNo( "41131001-299-101-AS" ) );


Do you mean, leave the spaces preceding the 'S' but remove only the 'S'?
2 weeks ago

2 weeks ago