cfoley's Profile
Reputation: 1508
Grandmaster
- Group:
- Mentors
- Active Posts:
- 3,219 (1.62 per day)
- Joined:
- 11-December 07
- Profile Views:
- 43,691
- Last Active:
May 24 2013 09:15 AM- Currently:
- Offline
Previous Fields
- Country:
- GB
- OS Preference:
- Who Cares
- Favorite Browser:
- Who Cares
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Who Cares
- Dream Kudos:
- 225
- Expert In:
- Java
Latest Visitors
-
CY5 
23 May 2013 - 01:49 -
jon.kiparsky 
21 May 2013 - 07:03 -
Kurt_Ryuu 
13 May 2013 - 04:53 -
vks.gautam1 
11 May 2013 - 01:09 -
The_Programmer- 
08 May 2013 - 14:47
Posts I've Made
-
In Topic: Card Game Task Using Classes
Posted 24 May 2013
You don't need the getters in the equals() method. Private means accessible only from that class. The catch is that separate instances are still the same class. This compiles, for example:
public class Card { private int value; private int suit; public Card(int value, int suit) { this.value = value; this.suit = suit; } public boolean equals(Card other) { return (value == other.value) && (suit == other.suit); } } -
In Topic: I've burned out
Posted 24 May 2013
That just isn't true. You can play the guitar no matter how rich or poor you are (as long as you have one to start with). Listening to music is also cheap and a lot of people do it in their homes, on their commute and at their work.
The gym can be expensive but it is something that is affordable as long as you are in gainful employment or are a student (since most universities have very cheap gyms).
Classes and travelling are more of a time issue than a money issue for most. However, I bet even the busiest people could find one evening a week, and everybody gets holidays, right? -
In Topic: Setting Windows Registry Values
Posted 24 May 2013
Before you do that, be aware it will only work on Windows and if you mess it up, there is a good chance of messing up your users' computers. Java Web Start is designed to add similar functionality to Java programs. I would at least look into it before playing with the registry. -
In Topic: Finding duplicate in arraylist except for zero
Posted 22 May 2013
Why not use Java's collections to your advantage? A good answer might be that this is for class.
As an aside, checkArray() is a bad method name. It doesn't tell you what you are checking for and it's lying about working with arrays. hasNonZeroDuplicates() is better and I'm sure there are better still.
import java.util.*; public class Duplicates { public static void main(String[] args) { reportResult(1, 2, 3, 4, 5); reportResult(0, 1, 2, 3, 4, 5, 0); reportResult(0, 1, 2, 3, 4, 1, 2, 5, 0); reportResult(1, 2, 3, 4, 1, 2, 5); } public static void reportResult(Integer... list) { System.out.print(Arrays.toString(list)); String indicator = hasNonZeroDuplicates(Arrays.asList(list)) ? "has" : "does not have"; System.out.println(" This list " + indicator + " non-zero duplicates."); } public static boolean hasNonZeroDuplicates(List<Integer> list) { return hasDuplicates(removeAllInstances(list, 0)); } public static <T> List<T> removeAllInstances(List<T> list, T item) { List<T> copy = new ArrayList<>(list); while (copy.remove(item)) { // Keep going until remove() returns false. } return copy; } public static <T> boolean hasDuplicates(List<T> list) { Set<T> set = new HashSet<>(list); return list.size() != set.size(); } } -
In Topic: The 14 Characters You Meet as a Coder
Posted 21 May 2013
Quote
when asked to write a program to output text from a regular text file, in his native language of course, he couldn't do it.
I think I'd run into issues with that too. My native language is English.
My Information
- Member Title:
- Cabbage
- Age:
- 31 years old
- Birthday:
- April 7, 1982
- Gender:
-
- Location:
- Glasgow
- Forum Leader:
- Java
- Years Programming:
- 20
Contact Information
- E-mail:
- Click here to e-mail me
- Website URL:
-
http://
|
|


Find Topics
Find Posts
View Reputation Given



|
Comments
burakaltr
06 Mar 2013 - 18:18cfoley
18 Oct 2011 - 03:29Dogstopper
18 Oct 2011 - 03:24ayaz 786123
25 Feb 2011 - 06:49cfoley
16 Feb 2011 - 17:26m-e-g-a-z
16 Feb 2011 - 15:34Dogstopper
08 Jan 2011 - 23:49cfoley
06 Jan 2011 - 16:19Dogstopper
06 Jan 2011 - 14:36DaneAU
08 Sep 2010 - 09:19I don't have many comments either, so i am only doing what the thingy below said to do, hello cfoley and thanks for the thanks :)