Forum: Java Apr 29th, 2009 |
| Replies: 10 Views: 893 If you post your files, people will be more willing to help because it gives them time to look at your logic and help you understand which steps to take to complete your project. |
Forum: Java Nov 22nd, 2008 |
| Replies: 7 Views: 937 Unfortunately, the implementation of ArrayList<T> looks [something] like this--
//... necessary imports
public class ArrayList<T> extends List<T> implements Collection<T>, Serializable{
... |
Forum: Java Nov 22nd, 2008 |
| Replies: 7 Views: 937 You'll probably have to reposition your read-stream cursor after each object read, otherwise you won't retrieve the right byte value from the file to match the data type(s) for the Object you are... |
Forum: Java Nov 12th, 2008 |
| Replies: 8 Views: 759 Chances are likely that your Instructor wishes for both your getArms and getLegs methods to return an array of Limbs--
Arm[] getArms(){
return arms;
} |
Forum: Java Nov 12th, 2008 |
| Replies: 28 Views: 1,727 If you work in an environment similar to mine, you'll have people telling you to "GIYF!" quite a bit XD.
If there is a term you don't understand, you should definitely study it. I find it much... |
Forum: Java Nov 10th, 2008 |
| Replies: 28 Views: 1,727 Reflection is a very specialized solution, much like the Java Native Interface, Remote-Method Invocation, Wildcards, Design Patterns, transient values, volatile values, concurrency, etc.
Don't... |
Forum: Java Nov 8th, 2008 |
| Replies: 28 Views: 1,727 Use either TreeMap (http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html) or HashMap (http://java.sun.com/javase/6/docs/api/java/util/HashMap.html)
Dictionary is also an okay way to go,... |
Forum: Java Nov 2nd, 2008 |
| Replies: 4 Views: 626 http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html
import java.math.BigInteger;
public class TestingBigInteger{
public static void main(String... args){ |
Forum: Java Oct 23rd, 2008 |
| Replies: 10 Views: 887 Yes, I am very sorry for mixing static fields and members. Fields execute once and only once when the first object of the type is created (otherwise if a program executed all static fields of all... |
Forum: Java Oct 23rd, 2008 |
| Replies: 10 Views: 887 static values are resolved at compile time, before objects are created.
A static member of a class is a shared location in memory between objects of that class.
Because static values are... |
Forum: Java Oct 22nd, 2008 |
| Replies: 12 Views: 1,726 It may be possible that Java won't support an image-type in future releases and therefore not provide Serialization support for it but that depends on what it is.
I remember getting warning... |
Forum: Java Oct 16th, 2008 |
| Replies: 4 Views: 793 I don't believe Menus or certain 'Views' would be possible without some type of Composite structure, so a reference to a Collection (or more appropriately, a Composite) within a Collection is good... |
Forum: Java Oct 16th, 2008 |
| Replies: 4 Views: 793 Ok, let me see if I understand what you're asking.
Let's first determine what a collection is.
Collection (programming) - a structure that holds many objects of some type (in old versions of... |
Forum: Java Oct 14th, 2008 |
| Replies: 3 Views: 3,565 This managed to work for me--
import java.util.*;
public class TestClass1{
static String seatLayout = null;
static String fn = null;
public static void main(String... args){ |
Forum: Java Oct 14th, 2008 |
| Replies: 11 Views: 1,353 You could use a State Machine, or State Pattern based on how many times an object has been encountered, or the State of an object can depend on the type of object it encounters...
It may simplify... |
Forum: Java Oct 13th, 2008 |
| Replies: 11 Views: 1,353 Would an Adapter be overkill?
I.E.
public class AdaptedA<T extends A> extends A{
private T myType = null; |
Forum: Java Oct 13th, 2008 |
| Replies: 11 Views: 1,353 Bah, disregard this post >_<
public <T extends A> void doSomething(T type){
if(type instanceof [SpecialNeedClass]){
// typecast only for this type
}
//... |
Forum: Java Sep 24th, 2008 |
| Replies: 5 Views: 1,028 This might help--
public class NullTest{
public static void main(String... args){
Object obj = null;
System.out.println(determineNull(obj));
obj = new Object(); |
Forum: Java Sep 24th, 2008 |
| Replies: 4 Views: 500 I marked the Thread daemon as a good practice. Unfortunately it makes the example hard to see, the way the code is currently written. Consider this example instead--
import javax.swing.*;
... |
Forum: Java Sep 24th, 2008 |
| Replies: 5 Views: 649 Though Stephen has already pointed this out, you need to get rid of the access modifiers when declaring data types in your main method.
The reason is because it is irrelevant for a method to have... |
Forum: Java Sep 24th, 2008 |
| Replies: 4 Views: 500 Why exactly does class B have to extend A?
From an immediate glance I can see a potential cycle instantiation issue.
Think about it--
1) Class A, after static initialization, will... |
Forum: Java Sep 20th, 2008 |
| Replies: 3 Views: 761 Because I don't like to repeat myself (http://www.daniweb.com/forums/thread142503.html) =P |
Forum: Java Sep 16th, 2008 |
| Replies: 10 Views: 1,003 Sometimes the best way to test to see if something is concurrent or not is to use a tracing technique.
Basically split the code that is shared by threads onto different pieces of paper and pretend... |
Forum: Java Sep 16th, 2008 |
| Replies: 10 Views: 1,003 Here's yet another example, though probably overkill--
import java.util.concurrent.*;
import java.net.*;
public class ConcurrentExample{
public final ExecutorService es;
private Future... |
Forum: Java Sep 16th, 2008 |
| Replies: 10 Views: 1,003 I don't think it's the run method that isn't executing, Peter.
I think the problem is that you are not submitting a Runnable target as the argument for the Thread to execute.
I actually don't... |
Forum: Java Sep 14th, 2008 |
| Replies: 2 Views: 1,617 Maybe this will do the trick?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Ball extends JApplet implements MouseListener {
private MyThread blueBall[]... |
Forum: Java Sep 13th, 2008 |
| Replies: 6 Views: 1,672 After running some tests I realized that somehow your transform is jumping between 1-22 on the (result?) matrice--
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;... |
Forum: Java Sep 9th, 2008 |
| Replies: 3 Views: 4,386 From what I understand, all objects are saved as .dat files for Java to reinterpret back into an object during deserialization.
To save files with an extension, I'd assume you'd use... |
Forum: Java Sep 9th, 2008 |
| Replies: 9 Views: 2,006 Yes, this version is much easier to understand.
Also the DataInputFilterStream is flawed and will only work for the InputStream provided by the System class, and does not work well with files.
... |
Forum: Java Sep 9th, 2008 |
| Replies: 9 Views: 2,006 This approach was probably unnecessary, but I took it anyways.
Try this--
import java.io.*;
public class DataInputFilterStream extends FilterInputStream{
public... |
Forum: Java Sep 1st, 2008 |
| Replies: 4 Views: 5,521 Personally I'd read all of the characters into a String then tokenize the String based on the space character. |
Forum: Java Aug 30th, 2008 |
| Replies: 4 Views: 5,521 The problem is that your Charact method is stuck in the while loop. You obtain the length of the file and state the conditon numChar != -1.
Keep in mind what data types are for. They store a copy... |
Forum: Java Aug 30th, 2008 |
| Replies: 12 Views: 1,088 Errors 1, 2 (and most likely 3) are generated because third.getPages is being parsed as a variable that exists within the Class associated by the object third.
total=first.getPages()+... |
Forum: Java Aug 25th, 2008 |
| Replies: 11 Views: 3,378 There are a lot of questions...
First, will resizing the screen be an issue at all? If not then you could make a custom track using GeneralPath and Graphics2D fairly easily.
You could do so... |
Forum: Java Aug 25th, 2008 |
| Replies: 11 Views: 3,378 Why not g.fillOval()?
Also, will repainting be an issue? How much detail will be displayed on your screen? Are you at all using images?
A lot of questions come to mind since this seems like an... |
Forum: Java Aug 22nd, 2008 |
| Replies: 14 Views: 3,010 Do you want to draw an image from a file, or do you want to be able to "rotate" a set of pixels such that they emulate a rotating String?
This can be either really simple or hard depending on... |
Forum: Java Aug 22nd, 2008 |
| Replies: 8 Views: 1,615 I suppose you're using a GCanvas, or most likely the GraphicsProgram from the acm.program package?
You could have GCanvases pre-painted with components and when you advance a level, simply set the... |
Forum: Java Aug 22nd, 2008 |
| Replies: 8 Views: 1,615 Although I haven't attempted it before, I'd assume you'd have a particular zone renderred on the screen with a type of "cover" over it. Either that or only render certain pixels ahead of the borders... |
Forum: Java Aug 21st, 2008 |
| Replies: 3 Views: 748 Javascript is in the web development section, not here =/ |
Forum: Java Aug 17th, 2008 |
| Replies: 7 Views: 1,346 I didn't pay close attention to the first post. Apparently JFrame has an initial Layout of BorderLayout.
The OP added the TextArea to the Center Border. By simply adding the JMenuBar, I suppose it... |