Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you import <strong>javax.swing.JFrame;</strong> then you use <strong>public class Authenticator extends JFrame {</strong> if not then use <strong>public class Authenticator extends jvax.swing.JFrame {</strong> <br>But the second method is mostly used when you have classes with same name in different pakage, to differentiate the classes. <br>for example<br> [-]mypackage<br> &nbsp;|----[-]pakage1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |---TestClass.java<br> &nbsp;|----[-]pakage2<br> &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|---TestClass.java<br></p> <p>Here is the situation we have a package named mypackage and two sub packages pakage1 and pakage2</p> <p>now if we just import it will give this<br></p> <pre><code>import mypackage.pakage1.TestClass; import mypackage.pakage2.TestClass; class Testw { public static void main(String []args) { System.out.println("Swah!"); } } </code></pre> <p>it will give following error<br></p> <pre><code>C:\Program Files\Java\jdk1.6.0_38\bin&gt;javac Testw.java Testw.java:2: mypackage.pakage1.TestClass is already defined in a single-type import import mypackage.pakage2.TestClass; ^ 1 error </code></pre> <p><br></p> <p> so what you do? <br> In this case you use the second method which is also called fully quailfied name now you import one pakage and use fully qualified name for other. </p> <pre><code>import mypackage.pakage1.TestClass; class Testw { public static void main(String []args) { TestClass testclass1 = new TestClass(); mypackage.pakage2.TestClass testclass2 = new mypackage.pakage2.TestClass(); System.out.println("Swah!"); } } </code></pre> <p>So the summery of whole thing is that fully qualified name is used when their is name clashing, we can also use this method when their is no name clashing ,their will be no -ve effect on program</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload