Results 1 to 6 of 6
  1. #1
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default cannot be applied to (int)

    What does this mean? The caret is pointing to test in the System.out.println statement.

    Ex6e.java:15: test(int,char,double,int) in Ex6e cannot be applied to (int)
    System.out.println(test(x));
    ^
    1 error

    Java Code:
    import java.util.*;
    import javax.swing.JOptionPane;  
    	 
    	public class Ex6e {
    	
    	public static void main(String[] args)  {
    	}
    	public static int test(int x, char ch, double d, int y) {
      		
      		x = 5;
    		ch = 'z';
    		d = 7.3;
    		y = 5;
    		
    		System.out.println(test(x));
    		return (x);
    	}
     }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,383
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lala View Post
    What does this mean? The caret is pointing to test in the System.out.println statement.

    Ex6e.java:15: test(int,char,double,int) in Ex6e cannot be applied to (int)
    System.out.println(test(x));
    Your method test( ... ) takes four arguments but you're only supplying a single int parameter; that's what your compiler is complaining about.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default cannot be applied to (int)

    Thank you, Jos.

    After making adjustment to System.out.println statement, why isn't anything prnting?

    Java Code:
    System.out.println(test(x, 'z', 7.3, 5));
    		return (x);
    	}
     }

    Output after execution:
    ----jGRASP exec: java Ex6e


    ----jGRASP: operation complete.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    1) you've got nothing in main method so nothing will happen.
    2) If you did fix main method, it looks like you've got a bit of recursion going on where the test method calls itself repeatedly. What are you trying to do?

  5. #5
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default cannot be applied to (int)

    Other than trying to climb out of the hole i fell in :), I am trying write an example of an overload method, & then print the parameters/variables of that overload method. I am trying to print what is in the method test. This should just be a simple demo of an overload method. Do I even need a main method ?
    Thanks In Advance

    Java Code:
    public static int test(int x, char ch, double d, int y)

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,383
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lala View Post
    Other than trying to climb out of the hole i fell in :), I am trying write an example of an overload method, & then print the parameters/variables of that overload method. I am trying to print what is in the method test. This should just be a simple demo of an overload method. Do I even need a main method ?
    Thanks In Advance

    Java Code:
    public static int test(int x, char ch, double d, int y)
    The JVM doesn't know that you only want to test overloaded methods. All it can do is find a public static void main(String[] args) method and start that. So yes, you do need a main( ... ) method to start everything going.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Font type not getting applied
    By afreaz in forum New To Java
    Replies: 5
    Last Post: 03-03-2010, 01:55 PM
  2. operator || cant be applied to OlimpicFrog, boolean
    By darkblue24 in forum New To Java
    Replies: 2
    Last Post: 02-16-2010, 12:37 AM
  3. Replies: 4
    Last Post: 01-29-2010, 09:57 PM
  4. Error: cannot be applied to (java.lang.String)
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 06:33 AM
  5. Replies: 1
    Last Post: 08-01-2007, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •