• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Getting output of other class.

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying this...
In a common package (in eclipse) i placed two files as follows:-

1) p1.java

public class p1 {
public static void main(String[] args)
{
System.out.println("Hello!");
p2 p = new p2();
p.disp();
}
}
class p2
{
void disp()
{
System.out.println("From class p2");
}
}

2) p2.java

class p3
{
// strange!! execute this file we will get output of p1.java
}
class p4
{

}



if we will execute p2.java it shows output of p1.java
please explain.
 
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might be using this command for execution-
java p2
 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if you can please provide complete code with command line options
 
reply
    Bookmark Topic Watch Topic
  • New Topic