No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
13 Posted Topics
[CODE] if(animals[i] instanceof Cat) ((Cat)animals[i]).makeNoise();[/CODE] The if statement here is saying if the Object contained in the Object array animal, at index i, is a Cat object then execute [icode]((Cat)animals[i]).makeNoise();[/icode] Because animals is an array of Object, if you try this [icode]animals[i].makeNoise();[/icode], you will get an error, because animals[i] will …
It's not too hard to do a basic version of this. All it involves is creating a Thread for each client that connects to the server. So if client A is being processed with thread A, and client B with thread B, any messages thread A sends will go to …
James is right, this is taken from Suns Java tutorials on Primitive Data Types: [QUOTE]boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. [B][I]This data type represents one bit of information, but its "size" isn't …
Theres a LOT of code there.. But I think your problem is as follows: In the Product class you've defined the constructors as follows: [code=java] public Product(String Model, double restockFee, String Name, String stockNumber, int Units, double Price) and public Product(String Model, String Name, String stockNumber, int Units, double Price) …
Haven't used generics in a while, but is something like this what your looking for: [code=java] import java.util.ArrayList; public class GenericTest<T> { private Class<? extends T> instance; public GenericTest( Class<? extends T> instance ) { this.instance = instance; } public <T> void addNewTo(ArrayList<T> list) throws InstantiationException, IllegalAccessException { list.add( (T) …
You are trying to turn something into an Integer that cannot be turned into an Integer. You are trying to turn "A,Jan-02-2007,11,table,10.56,1" into an Integer, which you can't do.. That is why you are getting a [icode]NumberFormatException.[/icode] What exactly do you want to turn into an Integer..?
Always remember, the Java API is your greatest weapon! :) [url]http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html[/url]
If your program uses the command line, then I believe it will be the shell/consoles job to catch the enter or any other key press and not the actual java program. There may be a way to do it from the console ( probably using java.lang.Runtime ), but it can …
Instead of using Character.isDigit( char ), you could use the matches() method from the String class. This would save having to test the length of the data and having to convert it to a char. [code] import javax.swing.JOptionPane; public class Test { public static void main(String[] args) { String input; …
You can do this by reading the file /proc/version. I contains the kernel version, distro name/version and more information. It should exist in all distributions. I actually only found this out today! :) EDIT: It seems like I was wrong, only some of the major distributions add the actual distro …
You should look up the modulus operator ( which in java is % ) to solve this problem..
For a sorting algorithm ( or any class for that matter ) that can work for ANY type, user defined or not, you are going to have to know a bit about Generics in java. Also, for a sorting algorithm those types must be comparable. If you do not know …
DataOutputStream will write the int as bytes to the file, that is why strange symbols are appearing. If you want the int to be displayed as is, you should use an Object like a PrintWriter instead.
The End.
chaospie