masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

As soon as an object is no longer referenced it will be garbage collected (at the next GC run). If the only reference to that list was in that method, then yes, that list will be eligable to be GCed as soon as the method returns. Not that that method will work in that manner, as you can only add objects, not primitives to a collection, and since you did not generitise that list with <Integer>, autoboxing will not happen (the VM does not autobox to Object, it autoboxes to relevant Number types).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, if you meet one, introduce it to me, too.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

well, first of all thanks for all the inputs. it is the code given by my professor and for us to modify and add things he wants us to add. so please do not assume too early people here are just lazy bums. i would say lazy student wouldn't even bother posting questions.

Well, I would say a non-lazy student would post the questions and his answers to them and ask for corrections and/or confirmation. Simply posting a homework assignment is lazy. It shows that the only effort you are willing to give to your assignment is to ask for somebody to do it for you, i.e. no real effort at all.

stephen84s commented: eggjactly +6
masijade 1,351 Industrious Poster Team Colleague Featured Poster

hi, i just have many questions regarding abstract class, please briefly explain if you may. thanks.

1. what is the difference between declaring public abstract class and abstract class ?

Well, what's the difference between declaring public class and class?

2. should abstract class have a constructor? i know by default it has one, but since abstract class doesn't have an object and its constructor cannot be instantiated, then why we need a constructor?

For subclass constructors to use, maybe, you think?

3. does abstract class normally have public methods?

An abstract class can and does have, just about, anything you want it to have.

4.does abstract class have concrete functions as well? and why would we have full function in an abstract class?

If most, if not all, subclasses would do the some of the same actions, then what is the point of each subclass having to define that action?


lastly, what is wrong with my Customer constructor() in the customer class?

abstract class CD 
	{
		double interest_rate;
		int months;
		
		public CD(double interest_rate, int months)
		{
			this.interest_rate= interest_rate;
			this.months= months;
		}
		
		abstract double calc_interest();// this method is not finished !!!
	
		public String toString()
		{
			return ("Interest Rate: "+ interest_rate + "\n" +
					"Months: "+ months +"\n");
		}
		
	}

	class Customer extends CD 
	{
		String name;
		String address;
		double deposit;
		
		// default constructor 
		public Customer()
		{
			name = "no name";
			address = "no address";
			deposit = 0;
		}
		
		// constructor 
		public Customer(String name, String address, double deposit)
		{ …
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ach, I meant to change that. It should, obviously, be

cir.computeArea();

not

child.computeArea();

but it doesn't need to casted. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But for that too computeArea() should be static.
OR
It should be called with the object name (cir) casted to child.

No, computeArea is declared in abstract1, so it perfectly legal to be called on an instance referenced as an abstract1 instance. And if the actual instance has overriden that method, then the overridden version will be used. This is how it is suppossed to work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have the feeling what you actually meant to do, was this:

public class One {
    public static void main (String[] args) {
        int side=5;
        abstract1 cir = new child(side);
        child.computeArea();
    }
}

However, since computeArea is void, and you do not "print" anything from that method, you will get no visible clue (except that it produced no error) that it successfully ran.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because "abstract1" does not declare that method, it cannot be called on an instance that is referenced as an abstract1 instance. Either you have to cast or declare it as "child" or you have to declare an abstract "child(side)" method in abstract1.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Set the Content-type and content-disposition headers and send the bytes through exactly as you read them.

Edit: nevermind that. Set your file/program associations in FireFox.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Could be any number of things. Add a few "log" time statements to make a preliminary determiniation of where it's "bottlenecking".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Are you running from tomcat? If so, then place it in the common/lib or shared/lib (I can't remember which it is). Depending on how you configure your datasource web-inf/lib may be loaded from a different (and later in the chain) classloader than the datasource.

If you are running from Eclipse, currently, than, as I said in that last sentence, add it as an external library/jar to the project properties/preferences in Eclipse.

Once again, the only thing that causes that error, is that the class is not on the classpath for the classloader concerned.

There are three classloaders in every application. The bootstrap classloader (which loads rt.jar and the security packages), the system classloader (which loads the core java extension packages), and the application classloader (which loads the rest of the classpath). In web containers, each application also gets a fourth classloader for the classes contained within the application directory.

Now, depending on how you configured your datasource, it may be being loaded from the application classloader (which would mean that you need the jar in (common/shared)/lib) or the web applications classloader, which would then allow you to place the jar in the web-inf/lib directory. If you are actually running from tomcat, then it appears as though you need it in (common/shared)/lib (and I don't know why you haven't tried that already when it is mentioned in reply #4).

And see above if currently running from eclipse.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Reread the last sentence (the one in parenthesis) of reply #4.

Also, reread the part of that same post that says not to rely on the system CLASSPATH environment variable as containers (of which all IDEs are) will not use it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is not the same error.

For that one, make sure that your SQL Server is setup to respond to TCP IP connection attempts (per default, it is, AFAIK, not).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Look at the DeskTop class.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

No one told you to override paintComponent.

Load the image into a BufferedImage, get the Graphics2D, modify it, then create a ImageIcon from that.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Am new in the programming sector. I have a task that requiires me to join a java interface to mysql but I don't know the code to do that. Can you please help.

http://dev.mysql.com/doc/refman/6.0/en/connector-j.html

Next time start a thread.

I just wanted a small program in Java for eaxample that which can take only the names of employees and a short code in mysql to create a table for the names, then a code to link the the two, that is if its possible to you and that will be all.

Read that documentation, there are plenty of examples there (see the "examples" section of the docs, maybe). I am not going to give you something that you can just cut-n-paste and then use with only minor changes. This is for you to write, not me.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then why mention that you are a PHP developer?

That has nothing to do with the item at hand, and since that was the only thing that gave any indiciation about what this might deal with, we can only assume you wanted it in PHP.

Maybe this will help you a bit further (although it has been years since I have seriously done anything with Perl so this will be my last message here).

http://www.daniweb.com/forums/post250461-5.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then ask on the PHP forum, not the Perl forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, that's what you're telling to do (stay the original size, that is).

Try looking at the API docs for BufferedImage (and Graphics2D) and see if there is something there that can help you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

not to mention masijade gave him the entire solution

Well, the form of it anyway. Cut-n-paste code I do not do. ;-)

In either case, I have the feeling that his instructor will want to see a loop, two "save" variables, and two if statements, rather than Math.max, Math.min, or the easiest solution Arrays.sort(). ;-)

Of course, he didn't really state how the instructor worded the exercise, the instructor may even want to see a recursive method. Who knows? ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

try this one

import java.util.Arrays;

class max
{
public static void main(String args[])
{
int [] num = {40, 20, 10 ,5, 74, 15, 20,30,95,21};
Arrays.sort(num);
System.out.println("min value"+num[0]);
System.out.println("max value"+num[9]);
}
}

See reply 6.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
for (.....) {
  max = Math.max(max, ...);
  min ....
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, no, it didn't "solve his problem". It made it worse. Even if the thing does work (and I'm not saying that it does), how does this "solve his problem"?

Sure, he may be able to hand in this homework assignment today (for which it's probably too late already anyway), but what about tomorrow? When he needs to do the next assignment, which is designed to build on what he "learned" doing this assignment? Well, seeing as how he wouldn't "learn" anything by block copying and pasting this unformatted mess, how is he to deal with tomorrows assignment?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Besides, if you simply want to "take the easy way out", place your numbers in an array (which I assume they are already, anyway), and use Arrays.sort() and then pull the first and last numbers.

;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, Math.max and Math.min in a loop saving the result through each iteration. Once the loop is done, you have the max and/or min.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This part of the code

class calculateButtonHandler implements ActionListener
	{
		public static calculateButtonHandler chandler;

is declaring an inner class, which cannot have static types.

Declare this class outside of the class definition for OfficeAreaCalculator.

P.S. Not that I think that that is the only problem with your code, but then again, I didn't really even look at it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Still nothing to do with JSP though. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does a JSP have to do with Screen Resolution? It might, with a few JNI libraries, be possible to change the screen resolution on the server (although I have no idea why you would want to, or what it might bring you), but not the client (which is, seemingly, what you want). Although I have no idea how you think the two relate to each other.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, seeing as how the "withdrawal" method already has a variable "newBalance", simply check the value of that (that it is not less than 0 or is greater than or equal to 0) before reassigning back to "balance".

Although your check works, as well, of course.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm not sure which is worse. Having students use throws clauses or having so-called professionals write

try
{
    ...
}
catch (Exception e)
{
    e.printStackTrace();  // or whatever it is
}

For that reason, I think encouraging people to mindlessly catch exceptions is worse than having them mindlessly throw exceptions.

And the "so-called" professionals (as you say), won't do that, unless they are still in early debugging stages. They will, at the very least, log the error using one of the many logging packages available, then actually (can you believe this) attempt to handle the situation in a reasonable manner, so that the program can either continue, or reset back to a previous state without the program crashing down around their ears.

There is a reason that certain methods throw catchable exceptions. It is because those are errors that are, conceivably, recoverable. Simply declaring your methods to throw Exception so that you don't have to deal with them is infantile and idiotic "programming". Not really programming, at all.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? So what exactly are you having problems with? Please refer to the forum "rules". We are not going to "finish" this for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Suppossedly, he's tried reading the outputStream (see the getInputStream above), but, suppossedly, the "sub" program is simply not doing anything. That tells me that some error is coming, unfortunately, the OP won't see that, because the OP is neither reading the error Stream (getErrorStream()), nor evaluating the return code of the program (exitValue()), so it will look as though it is simply not doing anything.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try reading the error stream, as if an error occurs the message will go to the error stream not the outputstream (of the process inputstream from the program). And check the value of exitValue() (non-zero means an error occurred).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the API docs for ProcessBuilder

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Set your path (not classpath) or type the full path to the command

masijade 1,351 Industrious Poster Team Colleague Featured Poster
...
    private TextField x;
    ...
    public MyGUI() 
    {
        ....
        JTextField x = new JTextField(5);

The "textfield" you declare as an instance variable is not the same "textfield" you define in your constructor. And it is the one you declare that gets used in the actionPerformed method (which has never been defined, and so is null, per default).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

BURN THE HERETIC.
KILL THE MUTANT.
PURGE THE UNCLEAN.

FOR THE EMPEROR!!!!

Rape the horses and Pillage the women!
<Pause>
Ah, I mean .....

javaAddict commented: Dawn of War II is coming Feb 28 +5
masijade 1,351 Industrious Poster Team Colleague Featured Poster

who knows?

<raking metal cup across iron jail bars/>
Nobody (at least the trouble I'm in)!

It might help to know a few more details.

What is it doing, that it should not be?
What is it not doing, that it should be?
What compiler messages are coming (post them in their entirety)?
What exceptions are coming (post them in their entirety)?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It does an echo request on port 7 for users without "adminstrator" rights. If the user has adminstrator rights it does something else (although I don't remember, off-hand, exactly what).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, that's what you do. Take a look at the manual again, and see what other types of "patterns" that you can use in the same position that you currently have "13,16".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Not that it's really necessary (as there is a package dedicated to LDAP in the Standard JDK http://java.sun.com/javase/6/docs/api/javax/naming/ldap/package-frame.html ), but it does make things easier. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I guess it doesn't do what the OP is expecting:

Yep, oh well. ;-)

Nay, I had never actually looked at it, but I was assuming (and you know what they say about that word!) that it would return the default mapping (as it does exist). Oh, well, I guess common sense is too complicated (as common sense says it would return the default mappings). ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See all of the tables under http://java.sun.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html#1051555 to get started on it (and to get it right).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I haven't gone through the entire program of yours, no need to even, since there is much of repeatition. But what I have gathered from a quick look is that you need to avoid making all those classes. You are doing the same thing in all of them. Why not then make 25 instances (threads) of the same class. You can pass a parameter to the thread specifying the IP range it needs to scan.

Um, all those classes have been replaced with a single "parametrisised" class, now. ;-)

I still don't agree with the approach though.

Personally, I would use 20 threads and the "isReachable()" method.

Edit: That's if I were forced to do it. Personally I wouldn't do it at all, but hey, he's probably got his reasons, and they may even be good ones.

Edit Again: @OP I have not looked at the "video", and probably never will. Don't mean to be mean, but it is, at the moment, too much involvment for me at the moment to go through all that. I can only assume that it has, at least partially, to do with the fact that you are doing a good amount of work on the event thread, and I still don't see where you are starting threads for the purpose of reading the output and error stream of the started processes, so it is still very much possible that a buffer is filling up.