Results 1 to 12 of 12

Thread: Java help

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Java help

    So I am just getting the basics of java down, and I am creating this program and getting an error at this line:

    java Code:
    public void setDogLooks( int age,weight String dawg, boolean Mad ){

    "weight" cannot be resolved to a type.

    I'm not sure what's wrong?

    The whole program:

    java Code:
    import java.util.Arrays;

    public class Puppy{
       
       int puppyAge,weight;
       String DogType;
       boolean IsMad;
       //String [] dogs = {"black", "weiner"};

       
       public void CheckType ( ) {
           String [] dogs = {"blue", "weiner"};
           
           if(Arrays.asList(dogs).contains(DogType)) {

               System.out.println("Matched");
           }
            else {
                   System.out.println("Unkown dawg type");
            }
       }
       public void returnValues ( ) {
          System.out.println("Dog age:" + puppyAge + " Type:" + DogType);
       }
       public void setDogLooks( int age,weight String dawg, boolean Mad ){
           puppyAge = age;
           DogType = dawg;
       }

       public static void main(String []args){
          Puppy myPuppy = new Puppy( );

          myPuppy.setDogLooks( 2,15,"weiner",True);
          myPuppy.returnValues ( );
          myPuppy.CheckType();

       }
    }

  2. #2
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    public void setDogLooks( int age, int weight, String dawg, boolean Mad ){

    public void is similar to a procedure in pascal you need to declare the type of each input
    Last edited by tealc; 04-17-2013 at 12:03 AM.

  3. #3
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    try

    java Code:
    public void setDogLooks( int age, int weight, String dawg, boolean Mad ){

    Forum account issues? Please send me a PM

  4. #4
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    public void setDogLooks( int age, int weight, String dawg, boolean Mad ){

    public void is similar to a procedure in pascal you need to declare the type of each input
    thanks guys and thats exactly what i have been comparing it to, I just hate how errors in java don't explain what the problem is as much as it does on pascal/simba

  5. #5
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    It's funny, because I find Java errors more useful most of the time.

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    It's funny, because I find Java errors more useful most of the time.
    Meh I always found "invalid number of paramters" always more helpful then "blah blah blah cannot be resolved to a type"

    back when I played around with RSPS sources I used to use a .bat to compile the source and if I missed like a semi-colon I would always get spammed with exactly 100 errors of the same thing

  7. #7
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Meh I always found "invalid number of paramters" always more helpful then "blah blah blah cannot be resolved to a type"

    back when I played around with RSPS sources I used to use a .bat to compile the source and if I missed like a semi-colon I would always get spammed with exactly 100 errors of the same thing
    This is why most people use an IDE, much less hassle.

  8. #8
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by Richard View Post
    This is why most people use an IDE, much less hassle.
    IDEs are amazing, always catching the small errors before it's too late

    Forum account issues? Please send me a PM

  9. #9
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Quote Originally Posted by Justin View Post
    IDEs are amazing, always catching the small errors before it's too late
    Notepad or gtfo x3

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Notepad or gtfo x3
    I used notepad++ i thought i was so pro

  11. #11
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    I used notepad++ i thought i was so pro
    Seriously? Use eclipse it gives good error fixing suggestions

  12. #12
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    Seriously? Use eclipse it gives good error fixing suggestions
    Thats what i use i used notepad++ years ago

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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