Forum: Java Nov 22nd, 2008 |
| Replies: 7 Views: 960 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 12th, 2008 |
| Replies: 8 Views: 786 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 3rd, 2008 |
| Replies: 10 Views: 5,223 Solves simple string-based expressions.
Currently only supports integers, but can easily be expanded to support float-types. |
Forum: Java Nov 1st, 2008 |
| Replies: 19 Views: 1,267 This should be an easy project, until you have to create a command for executing an applet instead of a standalone application.
Also executing packaged-classes might be a bit tricky.
It will... |
Forum: Java Oct 22nd, 2008 |
| Replies: 12 Views: 1,765 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: 8 Views: 644 It might do you some good to learn RMI from the book Head First Java or get a brief overview by reading Head First Design Patterns. Both books are good and provide more information about programming... |
Forum: Java Oct 14th, 2008 |
| Replies: 3 Views: 3,689 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,375 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 2nd, 2008 |
| Replies: 0 Views: 437 I typically don't post anything unless I have a question or comment... but I am still trying to understand Serialization for Network-Applications and I ran into a brick wall (repeatedly) during a... |
Forum: Java Sep 24th, 2008 |
| Replies: 4 Views: 501 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: 1 Views: 3,612 There are a number of issues with the above code.
First of all, when declaring a variable (like menu), you should initialize it on the spot... even if it is a null initialization.
Secondly, you... |
Forum: Java Sep 22nd, 2008 |
| Replies: 5 Views: 592 Remive the semi-colon by your while-statement and you should be in business =) |
Forum: Java Sep 16th, 2008 |
| Replies: 10 Views: 1,008 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 7th, 2008 |
| Replies: 1 Views: 404 There needs to be some kind of simple commonality between classes.
An interface allows for many benefits via the implementation of the Object Model and how objects communicate with each other,... |
Forum: Java Aug 27th, 2008 |
| Replies: 4 Views: 997 An interface is a static context template that classes can implement. The methods within the interface have no body and must be of public access.
In addition, interfaces can also contain... |
Forum: Java Aug 25th, 2008 |
| Replies: 11 Views: 949 This worked for me--
import javax.sound.sampled.*;
public class test_sound {
private class MyThread extends Thread{
int seconds = 1, sampleRate = 8000; |
Forum: Java Aug 24th, 2008 |
| Replies: 6 Views: 643 Why not store the current time in a data type (like a long) when the key is pressed and when the key is released subtract the new time from the old time?
Here's an example--
public class... |
Forum: Java Aug 22nd, 2008 |
| Replies: 8 Views: 1,659 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 20th, 2008 |
| Replies: 3 Views: 478 I can already see you using the Bridge and/or Strategy pattern from the specs.
You'll also most likely end up using the Observer pattern.
Try not to be distracted by the specs too much. Break... |
Forum: Java Aug 1st, 2008 |
| Replies: 9 Views: 1,887 This is the error I'm getting when trying to load this using FireFox (after 3 attempts)
Java Plug-in 1.6.0_07
Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
User home directory =... |
Forum: Java Jul 31st, 2008 |
| Replies: 11 Views: 944 First and foremost I'd like to say that I'm damn impressed!
If I remember correctly, using switch/case statements yields much faster selection than if-else statements.
I don't think that's the... |
Forum: Java Jul 28th, 2008 |
| Replies: 40 Views: 3,494 There are a few ways we can do this.
In my opinion, the best way to do this is create a class that accepts these kind of values and stores them in appropriate data types (the types listed in each... |
Forum: Java Jul 25th, 2008 |
| Replies: 4 Views: 2,677 I found some links that rendered Images to .gifs, which seemed useless at first but then I looked into the Image class and all of the "helper" classes for its methods.
I think I'll try to look... |
Forum: Java Jul 24th, 2008 |
| Replies: 8 Views: 945 Here's a Generic extension of your max-value finder where anything that implements Comparable can be compared--
public class Manip{
public static void main(String... args){
... |
Forum: Java Jul 22nd, 2008 |
| Replies: 3 Views: 435 Since you used to be a programmer, I'd suggest for you to get used to using IDE's such as--
NetBeans 6.1 (or higher)
--there are others (I think JUnit is one) but this is a very good one that... |
Forum: Java Jul 21st, 2008 |
| Replies: 8 Views: 764 In the event that you need some tips for doing this project, refer to the following links--
http://www.daniweb.com/forums/thread135648.html
http://www.daniweb.com/forums/thread135617.html
... |
Forum: Java Jul 13th, 2008 |
| Replies: 10 Views: 972 It took me some time but I managed to whip up this simplified SizeableArray class that should answer most/all of your questions.
/**
// Hi Alex
// Thanks for your suggestion. I should have... |
Forum: Java Jul 10th, 2008 |
| Replies: 9 Views: 876 Let's break down the problem into steps...
->Accept user input
->Perform the desired operation / use recursion
->Prove that the operation has been done (by a display)
... these steps are in... |
Forum: Java Jun 28th, 2008 |
| Replies: 5 Views: 721 Remember that even strings/values can be split in half perfectly. You'll have to find a way to ignore the middle character in odd strings. You'll most likely want to make a method like this that... |
Forum: Java Jun 23rd, 2008 |
| Replies: 4 Views: 495 You could resort to absolute positioning, but in the event that the Panel is resized you may want to use a layout.
I'd suggest looking up the following in google--
Java class LayoutManager
... |
Forum: Java Jun 17th, 2008 |
| Replies: 3 Views: 1,953 Hello!
Have you heard of the interface Comparable?
It allows you to compare like-objects with its implementation.
public static void sort(Comparable[] values, int start, int end) |
Forum: Java Jun 14th, 2008 |
| Replies: 18 Views: 1,867 I've been looking into a few sites to see if group-parsing can be done in an easier fashion (i.e. parsing a group from the "deepest" paranthesized group then simplifying that expression and appending... |
Forum: Java Jun 5th, 2008 |
| Replies: 3 Views: 1,226 I think it has something to do with the way the stream works--
if you call the method nextInt it will return the value on the line and attempt to the next line of code.
I'm almost certain that... |
Forum: Java Jun 4th, 2008 |
| Replies: 13 Views: 8,261 import java.awt.*;
import java.applet.*;
public class graphic extends Applet {
Button button1;
public void init() {
}
public void paint(Graphics g) { |