Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Why can't I say just abs() or sin() instead of Math.abs() and Math.sin()?
Why can't I say just abs() or sin() instead of Math.abs() and Math.sin()?
✍: Guest
The import statement does not bring methods into your local name space. It lets you abbreviate class names, but not get rid of them altogether. That's just the way it works, you'll get used to it. It's really a lot safer this way.
However, there is actually a little trick you can use in some cases that gets you what you want. If your top-level class doesn't need to inherit from anything else, make it inherit from java.lang.Math. That *does* bring all the methods into your local name space. But you can't use this trick in an applet, because you have to inherit from java.awt.Applet. And actually, you can't use it on java.lang.Math at all, because Math is a "final" class which means it can't be extended.
2013-02-15, 1906👍, 0💬
Popular Posts:
What are the five levels in CMMI? There are five levels of the CMM. According to the SEI, Level 1 – ...
What is synchronization and why is it important? With respect to multithreading, synchronization is ...
How will you freeze the requirement in this case? What will be your requirement satisfaction criteri...
what is a service contract, operation contract and Data Contract? - part 1 In the below sample we ha...
I have 5 questions please give me the answer ,explanation,suggestions if any?? what is PMP(project m...