Results 1 to 4 of 4
  1. #1
    Zarquad is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Constructors/Modifiers/etc.

    I've been experimenting with creating my own variable times and whatnot (The terms are starting to get a bit confusing).

    Can someone tell me what's wrong with this program? It keeps telling me that t1 is unresolved, but I don't see why. I'm probably messing up the different types, as I'm still trying to understand the concepts.

    Java Code:
    public class Tile {
    	char letter;
    	int value;
    	
    	public Tile () {
    		this.letter = 'A';
    		this.value = 0;
    		
    	}
    	
    	public static void printTile (char letter) {
    		System.out.println (t1.letter);
    	}
    	public static void main (String[] args) {
    		System.out.println ("Hello");
    		Tile t1 = new Tile ();
    		tl.letter = 'B';
    		tl.value = 3;
    		printTile (t1.letter);
    	}
    }

  2. #2
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    263
    Rep Power
    2

    Default Re: Constructors/Modifiers/etc.

    the reference to the Tile object is named t1 not tl

  3. #3
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    263
    Rep Power
    2

    Default Re: Constructors/Modifiers/etc.

    and your printTile has an error too. t1 is not a variable or anything, print just letter.

  4. #4
    Zarquad is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Re: Constructors/Modifiers/etc.

    Oops. I fixed both. Thanks.

Similar Threads

  1. Help About Non-Access Modifiers
    By i_am.jayar in forum New To Java
    Replies: 3
    Last Post: 02-06-2013, 09:45 AM
  2. Access modifiers, why?
    By bubbless in forum New To Java
    Replies: 5
    Last Post: 11-02-2009, 01:40 PM
  3. Class Reflection: Finding class modifiers
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:11 PM
  4. Access modifiers
    By bugger in forum New To Java
    Replies: 5
    Last Post: 11-28-2007, 10:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •