NormR1 563 Posting Sage Team Colleague

Each thread could get the time it started by calling the System class's currentTimeMillis() method when it starts and call it later in execution and compute the duration the thread has run by subtracting the start value from the current value . When the user time has run out, the thread would exit.

NormR1 563 Posting Sage Team Colleague

results[4][5] = i; // problem here nothing gets stored

How do you know? Is the statement executed? It's inside of an if statement.
Add a println immediately after that statement that prints out the value of results[4][5] and the value of i. Then you'll see what was stored in the array.

NormR1 563 Posting Sage Team Colleague

Look at what is to be printed on each line. The first line has one number, the second line has two number. Each line starts with its line number and decrements. Make some loops that follows those rules.

NormR1 563 Posting Sage Team Colleague

I think JTextPane is the class to use. I can't find any sample code on my PC. Try Google.

NormR1 563 Posting Sage Team Colleague

Can you explain how these steps are done? What are the steps the program must do?

1)create another array to compare it against.

What is in this second array and how are its contents put into the array?

2)print out just the single numbers, not the duplicates

How does the program find the single numbers so it can print them?

dont fully understand

That's why you need to work on what steps the program is going to take to solve the problemn BEFORE writing any code for it.

NormR1 563 Posting Sage Team Colleague

Look at the prinf() method. It has formatting Strings that should help.

Also the String class's format() method could be useful.

Kronolynx commented: thanks +0
NormR1 563 Posting Sage Team Colleague

Pad the Strings in the first column with spaces so that they are all the same length.
say you want the first column to be 20 characters wide and the String to print is 15 chars long, then you need to add a String of 5 spaces to fill the first column to 20.
Make a method that takes the String and the width of the column and returns a new String with the input String padded with spaces to the width number of characters.

NormR1 563 Posting Sage Team Colleague

That looks like the normal contents of a browser's java console that is displayed when the browser uses the java plugin. It does not show that there are any problems.

NormR1 563 Posting Sage Team Colleague

I could find any .java.policy folder

The file's name is .java.policy (its a file not a folder) and is located in the user.home folder. Use the policytool to create it and save it in that folder.
Don't change any of the files in the JDK or JRE's folders.

If you could write code to override permissions, then permissions would be meaningless.

NormR1 563 Posting Sage Team Colleague

What have you written so far? Do you have any specific questions about your assignment?

jalpesh_007 commented: you're right. +3
NormR1 563 Posting Sage Team Colleague

What code have you written so far? Do you have any specific problems or questions to ask about it?
Post your code and your questions so we can help you get your code to work.

NormR1 563 Posting Sage Team Colleague

Try debugging the code by printing the values of the variables used in the draw() method to see where the fillRect() method is drawing.

NormR1 563 Posting Sage Team Colleague

Please explain what your problem is.
Ask some specific questions about what you are trying to do.

NormR1 563 Posting Sage Team Colleague

Please only start one thread per topic.

Arabian filly commented: sorry it was by mistake +0
NormR1 563 Posting Sage Team Colleague

Unsupported major.minor version 51.0

There is a version problem. The java plugin is older than the version of javac used to compile the class file. I think 51 is java 1.7. Look in the browser's java console window to see what version the plugin is.

NormR1 563 Posting Sage Team Colleague

Why does it look better? As coded, both objects have exactly the same content. That doesn't always make sense. Many times each object will have a different content, one will have the String a and the other the String b. What if you want a variable number of objects, each with its own contents?

NormR1 563 Posting Sage Team Colleague

confused about the fact that constructor only accepts String a

Look at the definition of the constructor and you can see that it takes just one String as an argument: public ClassObject2(String aStr){

The constructor would look like this if it took 2 Strings:
public ClassObject2(String a1, String a2){

NormR1 563 Posting Sage Team Colleague

Can you post the full text of the error messages you get.

Can you explain what problems you are having?

NormR1 563 Posting Sage Team Colleague

Can you add the needed import statements so the code will compile and also post the html needed to execute the applet so the code can be compiled and tested?

NormR1 563 Posting Sage Team Colleague
int digitValue = ch - 48;    // now the number is really 2

Poorly documented code. Who knows what 48 is.
Better would be:

int digitValue = ch - '0';    // now the number is really 3
NormR1 563 Posting Sage Team Colleague

Is this the same question: http://www.daniweb.com/software-development/java/threads/436236/sales-receipt-program-from-cash-register-program

Please don't start a new thread for the same question

NormR1 563 Posting Sage Team Colleague

Lots of people here to help. Can you explain your problem? Post the code you are having problems with and ask any questions you have.

NormR1 563 Posting Sage Team Colleague

I have not found anything that appears to have a null value regarding line 39 in Main_Class.

Try debugging the code by printing out the values of all the variables used on line 39. The printed values will show what variable is null.

NormR1 563 Posting Sage Team Colleague

why the upper two lines of code produce error!

Please post the full text of the error message.

One problem is that your class has the same name as a Java SE class. Changing the name of your class should fix those errors.

NormR1 563 Posting Sage Team Colleague

Can you iterate through the collection, test each object and put it in one of the new lists based on its value?

NormR1 563 Posting Sage Team Colleague

what is e.f(8,4,2)?

e is a reference to a class object. See E e = new E(5) where e is defined to be an instance of the class E
f is a method in the class referenced by e. See in the E class's definition public int f(int b, int c, int d)
8,4,2 are the three arguments passed to the f method

NormR1 563 Posting Sage Team Colleague

One way I work out the sequence of steps a program takes is to start at the main() method and number each statement in the order it is executed. A simple start:

    public static void main (String[]args)
        {
        E e = new E(5);                   // 1  
        System.out.println(e.f(8,4,2));
        }//main()


    public E(int z)                       // 2    
        {
        super(z);                         // 3
        }//Constructor

Another way is to add lots of println statements to display the results of all the computations as they are made in each method. This will require the the expressions be broken up into single steps so the results of each step can be printed.

ibthevivin commented: Thanks for the suggestion. It helps. +1
NormR1 563 Posting Sage Team Colleague

a DynamicArrayOfInts() object. what does that mean?

You create an object of a class with the new statement:
AClass aclsRef = new AClasss();

Here the variable aclsRef refers/points to a AClass object.

You cast a variable to a type by putting the type in ()s before the variable:
int x = (int)aVar; // cast aVar to an int

You can read about casting here: http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

NormR1 563 Posting Sage Team Colleague

how can i pass arguments

Are you passing the args to a class's constructor or to a method in the class?
It is coded the same way:
new ClassName(<the args here>);
aRefToTheClass.aMethodInClass(<the args here>);

See the tutorial: http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html

jalpesh_007 commented: nice artice... +2
NormR1 563 Posting Sage Team Colleague

txtOutput.append(temp.format); //I got red line under format why

The compiler can not find the field for the variable: temp
temp is a array of Strings. arrays have few fields. length is the ony one I know of.

What is that code supposed to do?

NormR1 563 Posting Sage Team Colleague

Can you post a small, complete program that compiles, executes and shows the problem?

At line 30 you get a reference to an array into aa5.
At line 32 you put that reference into temp

Now both HashMaps have references to the same array.

If you want to have two arrays, you need to define a second array and copy the contents of the first array. Then you would have two arrays that refer to the same objects.

NormR1 563 Posting Sage Team Colleague

but it will also modify the value in map-m1,

It sounds like there is a single object that is used as the value in both HashMaps. If you want separate objects with their own values, you need to create them. Copying a reference to an object does not create a new object.

NormR1 563 Posting Sage Team Colleague

after I press that button it causes the program GUI to stop

Where is the listener added to the button? Which button is being clicked that causes the GUI to stop?

The posted code has many compiler errors because of missing classes.

Can you make a small, complete program that compiles, executes and shows the problem.
Do NOT post all the project with hundreds of lines of code.

NormR1 563 Posting Sage Team Colleague

Take a look at the tutorial: http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html

You need to wrap any method that throws an exception in a try{}catch() block.

NormR1 563 Posting Sage Team Colleague

But it does not work

Please explain. Post a print out of the contents of the lists after the code executes.
Also add println statements that print out when a match is found and that print out the results of the remove() method (it returns a boolean).

Can you post a small complete program that compiles, executes and shows the problem?

Your code is only comparing elements at the same location in the two lists by using the same index i for both lists.

Also try using some of the other ArrayList methods.

NormR1 563 Posting Sage Team Colleague

I suggest that you start with a simple editor and use the javac and java commands in a console window before learning how to use an IDE.
See the tutorial about how to create some simple programs: http://docs.oracle.com/javase/tutorial/getStarted/cupojava/index.html

When you are able to write, compile and execute some simple java programs, then chose an IDE.

stultuske commented: second that. +14
NormR1 563 Posting Sage Team Colleague

How about moving the code out of the main() method to the constructor?
Or make t final so it can be used in the listener method.

NormR1 563 Posting Sage Team Colleague

how to add them up.

After the new number is obtained, add it to the variable that is to accumulate the total:
total = total + newNumber;

or shorthand way:
total += newNumber;

Can you post pseudo code for what you are trying to do? Make a list of the steps the code should take to do what you want done. Each step in the list should be as simple as possible.

gelmi commented: if i will put total += (what would i put here?) +0
NormR1 563 Posting Sage Team Colleague

Can you post the code you are having problems with?

pseudo code:
begin loop
read number
print "YES"
end loop

gelmi commented: sure thing. +0
NormR1 563 Posting Sage Team Colleague

The Applet class extends Panel which extends Component and could be added like any other Component to a Container like JFrame.
Does the applet use any Applet or AppletContext methods? Depending on which ones, you may be able to provide the services that the browser provides by setting the AppletStub and providing code for its methods etc

EDIT: Missed the "from URL". That could mean you would need your own classloader to read the class file bytes and load the class. Haven't done it that way myself.

NormR1 563 Posting Sage Team Colleague

I am not able to test the code because it does not include all the data it needs to execute. There are prompts made for input that should not be made but should be answered by having values in the the code. I showed you how to define the Scanner object so that it has the answers to all the prompts in it. See my previous post.

If you see what the problem with the code is:

"j" (at line 90) is not going after 6 instead of it has to go upto 20.

then you need to examine the code to see why that is happening. Add more printlns to show why the code is doing what it is doing.

jalpesh_007 commented: thnks for suggestion..i have completed it. +0
NormR1 563 Posting Sage Team Colleague

You will have to write some code to extract the numbers,the operators between the numbers and then do the arithmetic represented by the operators.
The String class has many methods that should help you.

NormR1 563 Posting Sage Team Colleague

What is the code supposed to do? I don't see any comments in the posted code describing what it does.

NormR1 563 Posting Sage Team Colleague

Read the line into a String and use one of the String class's methods to extract the first character.

NormR1 563 Posting Sage Team Colleague

how can I do this from the text file

Read a line from the text file, extract the first letter of the line and use an if statement to test it and do what it requests to be done.

NormR1 563 Posting Sage Team Colleague

The question is too general to be answered. You need to be much more specific about the program you want to write and show some effort by posting the code you are having problemw with.

NormR1 563 Posting Sage Team Colleague

Could you rewrite the code so that it includes the input it is reading?
For example replace the DataInputStream class with a Scanner class and create the Scanner object with a String instead of System.in
= new Scanner("the input for the class here\nwith lines\nand more lines\n");

That will make it much easier for anyone to test (no need to type input) and will make sure every one tests with the same data.

NormR1 563 Posting Sage Team Colleague

What is getValue() defined to return?

Can you post a small complete program that generates the compiler error?

NormR1 563 Posting Sage Team Colleague

Can you make a small program that compiles, executes and tries to do what you want done?
SOmething that we can use for testing.

NormR1 563 Posting Sage Team Colleague

Try asking on a Javascript forum. This one is for Java.