newbie question on void method


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: newbie question on void method

  1. #1
    Join Date
    Sep 2004
    Posts
    2

    newbie question on void method

    I just started learning java and this is part of my assignment.
    I was trying to allow my interface to run the the openAccount method. But it
    seems that I keep getting this error java:60:
    Customer(java.lang.String,java.lang.String,java.lang.String,int,java.lang.St
    ring) in Customer cannot be applied to ()

    Customer customer = new Customer();
    Part of my interface code is :
    public void AccBalance() throws IOException{
    BufferedReader in = new BufferedReader
    (new InputStreamReader(System.in));
    boolean done = false;
    while(!done) {
    System.out.println("Account Balance");
    System.out.println(" [O] Opening Account ");
    System.out.println(" [C] Closing Account ");
    System.out.println(" [D] Display Account ");
    System.out.println(" [R] Return To The Menu ");
    System.out.println(" ");
    System.out.print("Enter your selection (O, C, D or R) : ");
    System.out.flush();
    String option = in.readLine();
    System.out.println("");

    //Go according to their options for O, C, D or R
    if(option.equalsIgnoreCase("o")) {
    //System.out.println("o");
    Customer customer = new Customer(); ==> error, it seems that it can't
    openaccounts as the customer obj has no value
    customer.openAccounts();

    Inside my customer class, I have declared the customer instances variable
    and constructor. For example,

    public class Customer extends Account
    {
    private String custID;
    Customer(String custID)
    {
    this.custID = custID;
    }

    public static void openAccounts() throws IOException
    {
    System.out.print("Enter your customer id: ");
    // open up standard input
    BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
    String custid = null;
    // read the username from the command-line; need to use try/catch with
    the
    // readLine() method
    try {
    custid = a.readLine();
    } catch (IOException ioe) {
    System.out.println("IO error trying to read your name!");
    System.exit(1);
    }
    System.out.println("Thanks for the customer id, " + custid);(==> I thought
    this will be store in the memory as custid ..so by right they should be able
    to see in cust obj
    }

    can someone help me to point out how to go about it and get rid of the
    error?Or give me some example to enlighten me? Thanks a lot..

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    60:
    Customer(java.lang.String,java.lang.String,java.lang.String,int,java.lang.St
    ring) in Customer cannot be applied to ()

    Customer customer = new Customer();
    deciphered: on line 60 of your code
    you are attempting to use Customer's constructor, but you are not giving all the required arguments..

    in fact, youre giving no arguments at all, when a customer NEEDS the following:
    a string
    a string
    a string
    an int
    a string


    what these are, i dont know, but you cannot create a new customer object without them, hence the message: method(argument1, argument2...) cannot be applied to method()

    -

    an analogy might be your mum saying to you "go"
    you say go where?
    you understand how to go, but you need a destination, or a purpose
    what she actually wanted you to do was go to the shop and buy a loaf of bread.. but how could you know his, when she just said "go"

    youre jsut saying new Customer.. but youre not telling the compiler things it definitely needs to know, to carry out your bidding
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center