aspose file tools*
The moose likes Beginning Java and the fly likes why this code runs successfully???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why this code runs successfully????" Watch "why this code runs successfully????" New topic
Author

why this code runs successfully????

Puneet Mittal
Ranch Hand

Joined: Dec 18, 2007
Posts: 45

why this following code does'nt give any error as there are three main methods and the file is saved as "SIB.java". And even i have not declared class SIB as public.

<blockquote>code:
<pre name="code" class="core">
class A
{
static int i;

static
{
i = 10;
}

public static void test1()
{
System.out.println(i);
}

public static void test2()
{
System.out.println(i);
}

public static void test3()
{
System.out.println(i);
}

static
{
System.out.println(i);
}
}

class SIB
{
public static void main(String punnu[])
{
A.test1();
SIB2.main(punnu);
}
}

class SIB2
{
public static void main(String punnu[])
{
A.test2();
SIB3.main(punnu);
}
}

class SIB3
{
public static void main(String punnu[])
{
A.test3();
}
}
</pre>
</blockquote>
Sree Chinna
Ranch Hand

Joined: Jul 15, 2008
Posts: 42
First of all why you were expecting an error as no class has methods with same signature ?
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
this and this
should help you.

There are very few questions in java that are not already answered in the forums............


SCJP 6
How To Ask Questions On Java Ranch - How To Answer Questions On Java Ranch
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Hi Puneet,

Keep your posts in the same message, that will help others to know where and what doubts you have and clear them.......
Currently you are asking the same question in three messages.....
Puneet Mittal
Ranch Hand

Joined: Dec 18, 2007
Posts: 45

thanks sachin. can you please tell me that how can we send url to links of some posts with tags. actually i receive some links with tags as 'this'
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Use the URL button when you are replying.
A scripted window comes up asking you for the url and then the name you would like to suggest for the url.

Again ubb code can help..........

If you want to refer to any posts from other messages you can use the url button
Puneet Mittal
Ranch Hand

Joined: Dec 18, 2007
Posts: 45

thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why this code runs successfully????
 
Similar Threads
doubt on object
Doubt regarding private contructors
Covariant Question
Display the prime factors of a number using sets
Static initialization block?????