Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To clear the basic fundamental

 
dimple bav
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it is very silly but i just want to clear the funda:

what is the difference between code1 and code2

code1:

class A
{
}

class test
{
public static void main(String args[])
{
A a = new A();
}

---------------------------------------------------------
code2

class test
{
public static void main(String args[])
{
Test a = new Test();
}

Thank you.
Dimple.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you want to know?
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the first you are creating an instnce of class A...and in 2nd you are creating an instance of Test class
 
dimple bav
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju Champaklal wrote:what do you want to know?


But in the code 1 hows the instance of class A is related to Test class
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
since both are in same packages an instance of A class can be created anywhere within the same package or within any class in the file....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic