BestJewSinceJC 700 Posting Maven

Im also having a problem with when i create and put objects in the collection i use the key (above 502146) which is the registration of the object how can i set that to the registration within the collection? (when i print out the collection the registration is null).

You could use .keySet().toArray() and print out everything in the array it returns. You could also use .containsKey("registrationNumber") to see if the registration number is in the "Collection" (actually since you're using put to map key->value it is probably more specifically some kind of class that extends Map).

Also I have overided toString(), i have a bunch of types (eg. LargePlane, SmallPlane) that could be in this collection, how do i print like LargePlane? I've tried like typeOf() and stuff but it doesn't work, do i need to import something?

System.out.println(yourObject.toString()); I think you already know that, but I don't understand your question.

BestJewSinceJC 700 Posting Maven

You can also use scannerInput.nextLine() to grab an entire line of text. I don't understand what exactly you're trying to do though. If you give us some short sample inputs, and tell us what you want to happen after those inputs are read in, that would be helpful...

BestJewSinceJC 700 Posting Maven

Make a new thread. Ask your question in it.

BestJewSinceJC 700 Posting Maven

True, the same thing happened. I re-read the entire code and made changes, it's working now, but now I need some more help. I don't know the protocols to this forum well, so do tell me, I want to continue adding functionality to the code, if I need help on the new part, am I to mark this thread solved and start a new one or keep on asking in this one only.

That's really up to you, but I'd recommend to mark solved and start a new thread. Most people won't read through a thread this long to figure out what's going on.

BestJewSinceJC 700 Posting Maven

Just make an ArrayList<E> then add the Objects you need into the ArrayList at runtime. Create the Objects the normal way using the new keyword. Why doesn't that approach work for you?

BestJewSinceJC 700 Posting Maven

The ads don't bother me except for the large one at the top that constantly pops itself up when I'm trying to click on the forum name.

BestJewSinceJC 700 Posting Maven

Hard to believe that you're only 16. You've accomplished quite a lot .. I look forward to continuing to see you around the site!

:)

BestJewSinceJC 700 Posting Maven

Hey, welcome :)

BestJewSinceJC 700 Posting Maven

The game ends because you closed the socket between the client/server pair and because you have no while loop or other loop structure to facilitate each player taking turns. And I don't see why you're asking whether each should be a client or a server. You can't run a client without the server first being active anyway, so you should run the server first, then run the client. And the Client should have a separate class than the Server.

You should be using Sockets in order to communicate between your client(s) and your server. Check out this tutorial, it explains in detail and it has example code for single client-server pairs and for a server that can handle multiple clients.

BestJewSinceJC 700 Posting Maven

All you did was post your project description and your code.
http://java.sun.com/docs/books/tutorial/essential/concurrency/procthread.html
Read through this tutorial. Threads can cause problems and be challenging, but the basic principles are very usable.

BestJewSinceJC 700 Posting Maven

http://www.devx.com/tips/Tip/5697

That will help you locate resources using getResource(). Note that when you run a file, you are not running a .java file so it isn't like you can say "where am I?" and get back the location of a .java file.

BestJewSinceJC 700 Posting Maven
JOptionPane.showInputDialog(null, "Please enter a song title: " + Song.SENTINEL + " to quit:");

should be

title = JOptionPane.showInputDialog(null, "Please enter a song title: " + Song.SENTINEL + " to quit:");

and similar methodologies can fix the rest...

BestJewSinceJC 700 Posting Maven

hello world only has 10 alphabetic characters, not 11. What exactly do you want your program to do? In any case you can use the Character class's isSpace, isWhitespace methods, etc

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html

BestJewSinceJC 700 Posting Maven

Can you elaborate? The cache is "on chip RAM" - It sounds like you're saying that there is another cache* which stores the interrupt vector. Even if this is true, that doesn't explain how having pointers to lists of handlers saves any memory space. Are the lists of handlers stored in a different location other than the cache you're talking about? As far as the gates go, I'm afraid I don't understand. I thought accessing any location in the RAM took the same amount of time.

*when I say "another" cache I mean one other than the cache that is used to bridge the gap between RAM speed being slower than CPU speed.

Anyway, thank you for your reply.

BestJewSinceJC 700 Posting Maven

To be honest, you can completely ignore any & all rules if you simply put every possible combination of 0 and 1 in for A and B, and record the results. . then you will come up with your solution. Since you only have two variables it isn't like you have many things to test, 2^2 = 4.

0,0
0,1
1,0
1,1

BestJewSinceJC 700 Posting Maven

That's because you cannot use "==" except on primitive types. That means you can only use "==" on int, double, float, etc. For Objects, if you use "==" it is just checking to see if the memory address of "login" is the same as the memory address of "" (which is the empty String). Of course, these memory addresses are not the same, so it will never work. Anyway, the correct way to do it is this:

if (login.equals("")){
//do something in here
}
BestJewSinceJC 700 Posting Maven

No problem, glad I could help!

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

My book says that interrupt chaining is a "compromise between the overhead of a huge interrupt table and the inefficiency of dispatching to a single interrupt handler." I understand how the interrupt vector table works & why dispatching to a single interrupt handler is worse than choosing from an array. But I don't understand how it is any better to have one huge list of handlers residing in RAM than it is to have a smaller list of "pointers to handler lists" (I think the first option is better if it is possible to do). You'd still be using the same amount of memory, just in the second case the chunks are spread out . . right? I'm asking this because the way it is phrased it sounds like the issue here is that we're going to run out of contiguous RAM. I don't see why that is an issue given that the interrupt vector table is one of the first things set up when the OS boots and it seems to me that modern machines have more than enough memory?

If anyone could shed some light on this, it'd be much appreciated. :)

BestJewSinceJC 700 Posting Maven

Like I said, you should change your "set" method to "add". You should also have another method called "remove" that takes a String (the username) and attempts to remove it from the ArrayList. So any time the user logs on, they should be added to the ArrayList (meaning you should call the add method) and any time the user logs off they should be removed from the ArrayList. Keep in mind that it is possible for the user to attempt to log in more than once - your code should ignore the user's login attempts if they are already logged in. The ArrayList class has a contains method that will tell you (by returning true) if your User is already in the ArrayList.

BestJewSinceJC 700 Posting Maven

Ok, I see what you mean now. So on line 100, put

if (login == null) login = new Login(userName);

Putting that will have the effect of only creating a new Login if you haven't already created one before.

BestJewSinceJC 700 Posting Maven

In your Login class, you have a method called set. It should be called "add" because it adds a String to the ArrayList. And I don't see what line you're talking about. What line number is it on (as far as the line numbers to the left of your code that you posted in here)? Because it doesn't seem to be on line ten.

BestJewSinceJC 700 Posting Maven

If you go by most medals it was the U.S. If you go by most gold medals I think it was Canada.

BestJewSinceJC 700 Posting Maven

Since I keep seeing people asking how to read the Integers from a File, I figured this simple snippet might be useful. What it does is it creates a new Scanner Object based on the File Object "test.txt" then it reads all of the Integers from that file, skipping over anything else that was found in the file, and adding the Integers to an ArrayList. It then sorts the ArrayList and prints out the sorted numbers. The file must exist otherwise this example will crash.

BestJewSinceJC 700 Posting Maven

Hi Josh, welcome to the forums, looks like you have an array of languages under your belt already - where do you go to school?

BestJewSinceJC 700 Posting Maven

Hey Al, welcome to the forums. Hope you enjoy.

BestJewSinceJC 700 Posting Maven

You could start by getting a book from the library and reading about master theorem or by looking it up online. It isn't impossible.

BestJewSinceJC 700 Posting Maven

Since I've heard of Flex and not Tibco I know that my company is interested in Flex, but that doesn't mean yours is. Why not talk to someone at your company about the pros and cons of each?

BestJewSinceJC 700 Posting Maven

Do you think you might be able to use De Morgan's laws? http://en.wikipedia.org/wiki/De_Morgan%27s_laws

BestJewSinceJC 700 Posting Maven

Are you trying to run it in Eclipse? I think you have to tell it to run as a Java Applet under "Run as" if that is the case...

BestJewSinceJC 700 Posting Maven

Use a Scanner. Really, the exact way to do it depends on how your text file is set up, but here is a general tutorial on Scanner.

BestJewSinceJC 700 Posting Maven

Your not much of a ppl person are you? lol

Sorry if I came off rude. . what I was saying is, there's nothing wrong with asking for help, but I think it is important to use the resources at your disposal (i.e. the internet) before asking people to re-explain things. But my annoyance with the down-voting was admittedly misplaced.

BestJewSinceJC 700 Posting Maven

And what is your formula for monthly payment supposed to be? I don't have a mortgage currently, and I don't know that information. But I'd think it'd be based on the total amount of time you plan on paying off the mortgage over ..

BestJewSinceJC 700 Posting Maven

If you want to be assured that someone is using your work so badly, why not look for a job with a different company? But I agree with jwenting in that your focus should shift more towards taking pride in the work that you do and improving yourself rather than worrying about how often the finished product is used.

BestJewSinceJC 700 Posting Maven

http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html

^ A useful resource on how to make applets. Besides not needing the main method (if that is the case, which I think it is), you declared your main method incorrectly - you have a ";" after the closing parenthesis, which is going to cause errors.

BestJewSinceJC 700 Posting Maven

Down vote my post all you want, but you shouldn't expect hand holding - being pointed towards the thousands of resources available online about remainders should have been enough. And next time you get help, please be considerate enough to follow our rules, such as posting in code tags and marking the thread solved when you solve your problem.

BestJewSinceJC 700 Posting Maven

. . And will more than likely look nothing like it would if you wrote it.

BestJewSinceJC 700 Posting Maven

I see. This really seems like something more suited for a scripting language (i.e. run a script that would recursively compile and run all the java files in a certain directory and store their results in different result files, possibly named based on who the original author of the .java file was - which could be accomplished through regex probably). I'm not too sure though, that is more of a guess, so maybe someone else here can either confirm that advice or give better advice of their own?

BestJewSinceJC 700 Posting Maven

I think Cprog was down and I started searching for other forums. (And later, I was a bit of a Jul groupie.) After a while, I liked the features and things that I could do here that I couldn't on other sites. (Most of these have since been discarded.) My heyday was 2004-2006ish.

Out of curiosity, what were those features?

BestJewSinceJC 700 Posting Maven
public class ElectricityBill {
	public static void main(String args[]){
    current c1=new current(500,"January");
    current c2=new current(1600,"February");
    
    c1.print(c1.total,c1.month);//this is the place i wanna know,how to call print()
    c1.print(c2.total,c2.month);
    
	}
}

I think you should create print method outside of the class

His print method is already in the correct place, he is just calling it incorrectly.

BestJewSinceJC 700 Posting Maven

it should be print(total, month); not print(double total, String month);

BestJewSinceJC 700 Posting Maven

What about the next 15 times? Not quite as good? :(

BestJewSinceJC 700 Posting Maven

Look up what a remainder is on google. Our job isn't to teach basic math.

BestJewSinceJC 700 Posting Maven

Call the showOptions() method right after your call to getmeters(). And make showOptions an instance variable not a variable declared in main. Read about variable scope in Java if you don't know what I'm talking about.

BestJewSinceJC 700 Posting Maven

How could the remainder of 2/3 be higher than 2?

http://www.icoachmath.com/Controls/Remainder.html

BestJewSinceJC 700 Posting Maven

Re-read my reply. I edited it.

BestJewSinceJC 700 Posting Maven

Your Polynomial class does not have a getEx() method. In order to call the getEx() method it must exist.

edit: It's because your Polynomial class has a Node, and your Node class has a getEx() method. Therefore you must say

poly1.front.getEx()

(assuming your Polynomial is called poly1 and your Node inside that Polynomial is called front)

BestJewSinceJC 700 Posting Maven

Just put it in a zip file and post that zip file in this thread.

BestJewSinceJC 700 Posting Maven

Yeah - paste the error message along with the line number.

BestJewSinceJC 700 Posting Maven

Because you don't do your own homework. Or maybe it is because j++ already increments the variable j so storing that result into the variable j is redundant. Take your pick.

edit:

Oh, goodie. I just learned after reading your other thread that WaltP just told you the exact same advice I gave you about using j = j++ and similar statements.