LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-06-2006, 04:16 PM   #1
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Rep: Reputation: 32
learning java problem


I have this code :-
Code:
class BankAccount {
        private Nicholson int balance = 100;
        public int getBalance() {
                return balance;
        }
        public void withdraw(int amount) {
                balance = balance - amount;
        }}
public class RyanandMonica implements Runnable {
        private BankAccount account = new BankAccount();
        public static void main (String [] args) {
                RyanAndMonica theJob = new RyanAndMonica();
                Thread one = new Thread(theJob);
                Thread two = new Thread(theJob);
                one.setName("Ryan");
                two.setName("Monica");
                one.start();
                two.start();
        }
        public void run() {
                for (int x = 0; x < 10; x++) {
                        makeWithdrawl(10);
                        if (account.getBalance() < 0) {
System.out.println("Overdrawn!");
                        }}}
        private void makeWithdrawal(int amount) {
                if (account.getBalance() >= amount) {
                System.out.println(Thread.currentThread().getName() + "is about to withdraw");
        try {
        System.out.println(Thread.currentThread().getName() + "is going to sleep");
        Thread.sleep(500);
        } catch(InterruptionException ex) {ex.printStackTrace();}
        account.withdraw(amount);
        System.out.println(Thread.currentThread().getName() + " completes the withdrawal");
                } else {
        System.out.println("Sorry, not enought for" = Thread.currentThread().getName());
        }}}
When I compile it I get :-
javac RyanandMonica.java
RyanandMonica.java:12: cannot find symbol
symbol : class RyanAndMonica
location: class RyanandMonica
RyanAndMonica theJob = new RyanAndMonica();


Isn't it right.

This is an example I am doing from a self study course.
 
Old 01-06-2006, 04:25 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Common programming error number 17...

Check the case of your class and the data type you are using for theJob

RyanandMonica
RyanAndMonica

graeme
 
Old 01-07-2006, 04:41 AM   #3
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Original Poster
Rep: Reputation: 32
Thanks that is embarrasing ! The worst thing of all is that I can program python !
 
Old 01-07-2006, 08:09 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Don't worry we've all done it before

graeme
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning java problems davholla Programming 3 12-07-2005 07:55 AM
Optimal Java/C editor and learning resources jrdioko Programming 3 11-09-2005 09:22 AM
Learning Java davholla Programming 9 03-13-2005 03:13 PM
Questions in regards to learning C, C++ and Java... eBopBob Programming 8 12-21-2004 10:09 AM
Learning, Writing and Running JAVA. mooreted Programming 11 04-08-2004 09:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration