Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Xavier Figueroa
Greenhorn
+ Follow
6
Posts
1
Threads
0
Cows
since Apr 13, 2012
Xavier likes ...
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
Ranch Hand Scavenger Hunt
Number Posts (6/100)
Number Threads Started (1/100)
Number Cows Received (0/5)
Number Likes Received (0/10)
Number Likes Granted (0/20)
Set bumper stickers in profile (3/3)
Report a post to the moderators (0/1)
Edit a wiki page (0/1)
Create a post with an image (0/2)
Greenhorn Scavenger Hunt
First Post
Number Posts (6/10)
Number Threads Started (1/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (3/1)
Set signature in profile
Search for a post/thread (0/3)
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by Xavier Figueroa
* Welcome Edward Finegan and Robert Liguori
Welcome Edward Finegan and Robert Liguori, congratulations for this Excellent book
show more
11 years ago
Associate Certification (OCAJP 8)
Problem with return type in an overriden method
Thank you so much for your answer, I really needed this clarification and thanks for your Welcome
show more
11 years ago
Java in General
what's up with HashSet?
You need something like:
Iterator<Integer> it = products.iterator(); while (it.hasNext()) { answer = answer + it.next(); } ... }
or use an enhanced for loop
show more
11 years ago
Java in General
Problem with return type in an overriden method
Given this code:
class Animal { public Object voice(){ return "animal voice"; } } class Dog extends Animal{ public String voice(){ return "bark"; } } public class CastingTest { public static void main(String[] args) { Animal a = new Dog(); String s = a.voice(); System.out.println(s); } }
if i run this code i get
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - incompatible types required: java.lang.String found: java.lang.Object
Why I need to cast (String)a.voice() if the method called is a Dog Class member and has a String return type?
if i put the cast, y get
bark
show more
11 years ago
Java in General