Results 1 to 5 of 5
Thread: What is wrong with this?
- 03-07-2013, 08:17 PM #1
Senior Member
- Join Date
- Jan 2013
- Posts
- 137
- Rep Power
- 0
What is wrong with this?
When I run this code I get 7 errors. What am I doing wrong?
Java Code:public class Country{ String name; String continent; public Country(String n, String c){ name = n; continent = c; } public void PrintInfo(){ Country Argentina = new Country("Argentina", "South America"); Country China = new Country("China", "Asia"); Country UnitedStates = new Country("United States","North America"); System.out.println(name.Argentina+continent.Argentina); System.out.println(name.China+continent.China); System.out.println(name.UnitedStates+continent.UnitedStates); } public static void main(String[] args){ Country callit = new Country(); callit.PrintInfo("---","----"); } }
- 03-07-2013, 08:30 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: What is wrong with this?
Are you going to tell us the details of those errors or do you want us to guess?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-07-2013, 08:49 PM #3
Senior Member
- Join Date
- Oct 2010
- Posts
- 317
- Rep Power
- 3
Re: What is wrong with this?
Hi,
Your code on lines 9-14 should read Country.name and Country.continent.
PrintInfo on line 18 passes two arguments when the method signature on line 8 doesn't accept any.
Regards.
- 03-08-2013, 09:43 AM #4
Member
- Join Date
- Nov 2012
- Location
- India
- Posts
- 70
- Rep Power
- 0
Re: What is wrong with this?
your code have a problem with this line
you don't call like this.. you call like this..Java Code:System.out.println(name.Argentina+continent.Argentina); System.out.println(name.China+continent.China); System.out.println(name.UnitedStates+continent.UnitedStates);
And also your main method have problem with parameters. So you call like this...Java Code:System.out.println(Argentina.name+Argentina.continent); System.out.println(China.name+China.continent); System.out.println(UnitedStates.name+UnitedStates.continent);
Java Code:public static void main(String[] args){ Country callit = new Country("",""); callit.PrintInfo(); }Regards
Android developer at Trinay Technology Solutions,http://www.trinaytech.com,5705750475
- 03-08-2013, 09:59 AM #5
Re: What is wrong with this?
And variable names and methods are aways lower case!
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
Wrong output (well.. the one who's wrong is probably me ;) )
By shacht1 in forum New To JavaReplies: 4Last Post: 06-11-2013, 01:37 AM -
I can't find anything wrong with this but somehow it's wrong.
By Biscuit Tickler in forum New To JavaReplies: 2Last Post: 09-12-2012, 09:28 PM -
What am I doing wrong?
By DuncanHollows in forum New To JavaReplies: 2Last Post: 04-08-2012, 05:33 PM -
What did I do wrong?
By Astralogic in forum New To JavaReplies: 6Last Post: 04-05-2012, 12:16 PM -
What am I doing wrong?
By yankeefan9874 in forum New To JavaReplies: 1Last Post: 04-16-2010, 08:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks