Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: "The Beginner's Guide to Android Game Development" syntax and theory questions

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Location
    California for now
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "The Beginner's Guide to Android Game Development" syntax and theory questions

    I am just beginning my journey to becoming a Java programmer. I bought the beginner's guide book to facilitate my educational journey. I have come to a point where the code listed in the book brings about errors in my programming enviornment even before I run the code. I am using "Eclipse" as my programming enviornment.

    I created a new project call "Coder". This project has two classes, "World" and "Coder". The initialize method is a problem and calling upon the initialize method in the "Wold" class is a problem...for some reason.

    Can someone tell me what I am missing? In the "World" class, the [c.initialize ("Bill, 59")] is a problem, why? How else would I write this and why would this suggestion work. Why does what I wrote not work?



     
    public class World 
    {//start World class
     
    		public static void main (String [] args)
    		{//start main method
    			Coder c = new Coder();
    			c.describe();
    			System.out.println ("");
    			c.initialize("Bill, 59");
    			c.describe();
    		}//end main method
    }//end World class
    public class Coder 
    {//start Coder class
     
    	private String name;
    	private int age;
     
    	private void initialize (String name, int age)
    	{//start initialize method
    		this.name = name;
    		this.age = age;
    	}//end initialize method
     
    	public void writeCode()
    	{//start writeCode method
    		System.out.println (name + " is coding!");		
    	}//end writeCode method
     
    	public void describe()
    	{//start describe method
    		System.out.println ("I am a coder");
    		System.out.println ("My name is " + name );
    		System.out.println (" I am " + age + "years old");		
    	}//end describe method
    }//end Coder class
    Last edited by Norm; December 31st, 2019 at 05:02 PM. Reason: Changed end code tag \ to /

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: "The Beginner's Guide to Android Game Development" syntax and theory questions

    is a problem
    Please explain. If there are error messages, copy the full text and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2019
    Location
    California for now
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "The Beginner's Guide to Android Game Development" syntax and theory questions

    When I run the program I get this message

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method initialize(String, int) in the type Coder is not applicable for the arguments (String)

    at World.main(World.java:10)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: "The Beginner's Guide to Android Game Development" syntax and theory questions

    The method initialize(String, int) in the type Coder is not applicable for the arguments (String)
    The args: (String) being passed to the method does not match the what the method declaration requires: (String, int)
    "Bill, 59" is a String (enclosed in "s)
    change the String to a String: "Bill" and an int: 59 ("Bill", 59)
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2019
    Location
    California for now
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "The Beginner's Guide to Android Game Development" syntax and theory questions

    Norm,

    Thank you for your help. I implemented your suggestion and everything is good to go.

Similar Threads

  1. Replies: 4
    Last Post: July 18th, 2014, 02:04 AM
  2. Replies: 1
    Last Post: July 16th, 2014, 04:16 AM
  3. Replies: 2
    Last Post: May 22nd, 2014, 01:17 PM
  4. Conceptual Questions Related To "super" keyword and "constructor".
    By wikki2013 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2013, 02:14 PM
  5. [SOLVED] Syntax error on token "extends", throws expected
    By Purple01 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 16th, 2012, 07:29 AM