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 3 of 3

Thread: Simple Question

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Simple Question

    class Testing1{

    int a=10;

    void test1Methode(Testing1 testObj1){
    System.out.println(testObj1.a);
    }
    }

    class Testing2{
    int a=20;
    void test2Methode(Testing2 testObj2){
    System.out.println(testObj2.a);
    }

    }


    class Usethis{
    public static void main(){
    Testing1 Obj1=new Testing1();
    Testing2 Obj12=new Testing2();

    test1Methode(Obj1);
    test2Methode(Obj2);
    }
    }




    Can I send an Object of one class to other class. For Example, I used "test1Methode(Obj1);", it works with "Testing1" Class. Can I send Obj2 to the same class?? I mean "test1Methode(Obj2);".... Will this work?


    I tried, but not working. Why is this?


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Simple Question

    Your method call syntax is incorrect. Be sure you correctly understand concepts of OOP and it's implementation in Java. I advice you to consult official Oracle tutorial in order to learn the language basics.

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Question

    Quote Originally Posted by angstrem View Post
    Your method call syntax is incorrect. Be sure you correctly understand concepts of OOP and it's implementation in Java. I advice you to consult official Oracle tutorial in order to learn the language basics.
    Thank you....... :-)

Similar Threads

  1. Simple Question
    By Natural Noob in forum Java Theory & Questions
    Replies: 1
    Last Post: October 2nd, 2012, 07:26 AM
  2. One simple question...
    By chrish in forum Java Theory & Questions
    Replies: 15
    Last Post: June 27th, 2012, 11:15 AM
  3. Hi, i have a simple question.
    By oror84 in forum Java Theory & Questions
    Replies: 3
    Last Post: April 26th, 2012, 03:39 PM
  4. Simple I/O Question...well could be simple for you?
    By basketball8533 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 30th, 2011, 06:44 AM
  5. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM

Tags for this Thread