SRL Archive - General

Java help


rj

2013-04-16 19:42:33

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

   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:

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();

}
}

tealc

2013-04-16 20:00:47

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

Justin

2013-04-16 20:00:57

try


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

rj

2013-04-16 20:07:08

From: tealc
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

senrath

2013-04-16 20:10:57

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

rj

2013-04-16 20:20:20

From: senrath
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

Richard

2013-04-16 21:02:22

From: Officer Barbrady
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.

Justin

2013-04-16 21:23:08

From: Richard
This is why most people use an IDE, much less hassle.


IDEs are amazing, always catching the small errors before it's too late

Sin

2013-04-16 21:24:22

From: Justin
IDEs are amazing, always catching the small errors before it's too late


Notepad or gtfo x3

rj

2013-04-16 21:56:23

From: Sin
Notepad or gtfo x3


I used notepad++ i thought i was so pro

tealc

2013-04-16 22:05:06

From: Officer Barbrady
I used notepad++ i thought i was so pro


Seriously? Use eclipse it gives good error fixing suggestions

rj

2013-04-16 22:07:24

From: tealc
Seriously? Use eclipse it gives good error fixing suggestions


Thats what i use i used notepad++ years ago