1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Question about setting a value for x

Discussion in 'Software Development' started by OneLuv, Jul 8, 2007.

Thread Status:
Not open for further replies.
  1. OneLuv

    OneLuv Thread Starter

    Dec 28, 2006
    Part of the assignment said set the x and y values of start to 10. The code looked like:

    start.x = 10;
    start.y = 10;

    Can someone tell me why the start (dot) x ? I see in other parts of the code so far I have encountered g (dot)drawString.

    Or point me in the right direction to find out why. I can't remember to do somethings if I don't know why they are done.

    Thanks much:)
  2. Shadow2531


    Apr 30, 2001
    public class SomeClass {
        public int x; // public member attribute
        public int y; // public member attribute
    public class TestProgram {
        public static void main(String[] args) {
            SomeClass start = new SomeClass(); // create an instance 'start' of SomeClass
            start.x = 44; // Set start's public x member (which is an int) to 44
            start.y = 33;
    In the case of g.drawString(), g is an instance of the Graphics class and drawString is a member function of the Graphics class. Since you're dealing with the g instance, if you want to call drawString for g, you do g.drawString("string", 5, 5) for example.

    Is that what you mean?
  3. WARnux


    Jun 29, 2007
    Learn all about classes.
    Don't worry, it's a very simple concept, you'll get it.
    The . is how you access members of a class.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/593391

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice