John Valiant

Greenhorn
+ Follow
since Mar 01, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Valiant

Suppose A is equal to 10
and B is equal to 5.
Then if B is equal to A,
what is B?
11 years ago
Thanks fred, cant believe i missed it:)
11 years ago

Can anyone see my error?


ProblemSet5.java:63: error: ';' expected
System.out.println((GoldFish)owner.pets[ 9 ]).getAction("*Rat eats alot*" ));
^
1 error

11 years ago
ok, i cant put it to Pet as its an abstract class. So i have to cast it..what do you mean by it?How?
11 years ago
Wondering why i cant invoke my getAction?

Complier says
PSt5.java:60: error: cannot find symbol
owner.pets[ 4 ].getAction();
^
symbol: method getAction()
location: class Pet
1 error





11 years ago
ok it worked only when i overloaded it:(.GoldFish(){
}

11 years ago
Thanks Mohammad, managed to get things running but a few queries(pardon my ignorance).
1.Why didnt the complier recognize the below code as a constructor?

2.if i want to use the getAction() in ,let say, hamster,how can i go about doing that?
11 years ago



This time 1 error....errrrr any idea how to solve this?

23.java:37: error: constructor GoldFish in class GoldFish cannot be applied to given types;
owner.pets[2]=new GoldFish();
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
1 error
11 years ago
ok thanks but how can this be solved then? should i be making changes to array in class example?
11 years ago
Hi

My issue is i cant get the arrays correct,with abstract class.Can some one highlight to me the errors in class Example1.I want to create 2 extra pets (iguana & hamster) but i am getting it wrong.

below are the errors from my complier

23.java:37: error: constructor GoldFish in class GoldFish cannot be applied to given types;
owner.pets[2]=new GoldFish();
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
23.java:38: error: constructor Dog in class Dog cannot be applied to given types;
owner.pets[3]=new Dog("Hamster");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
23.java:39: error: constructor Dog in class Dog cannot be applied to given types;
owner.pets[4]=new Dog("Iguana");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
3 errors


11 years ago
Hi
Why am i getting error inthe below code?

11 years ago
Can anyone give me an example on how to initialise a non zero value using array?

12 years ago
Ok thanks will look up on loop.
12 years ago
Ok...bases on the hercules.length i want it to print 555555(derived from length).i am afraid you dont get it
12 years ago
String hecules ="strong";

System.out.println(hercules.length);
System.out.print("5");
System.out.println();
}
}

I want the output to be displayed like 555555.
What am i doing wrong?
12 years ago