Thread: Strange
View Single Post
Old 01-22-2013, 04:39 AM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Java can do this as well, but you should use it *very* sparingly. Keeping (and spoofing) the Foo:
PHP Code:
package foo;

public class 
Fou
{
    public static 
void Zap(String s)
    {
        
System.out.println(s);
    }
}

// And used:
package foo;

import static foo.Fou.Zap;

public class 
Lu
{
    public static 
void main(String[] argv)
    {
        
Zap("doFou");
    }

I really would not recommend this with Java, and especially with custom classes. But for shortcut (ie: lazy ) usage, you can use it against the system.out for example, so you can just type in out.println. Unlike C#/VB, you can't get to the println this way as the PrintStream is an instance object and not a class.
BTW, default functionality in languages like Java already use an implicit static import for the entire java.lang package. Without it you'd need to import or instantiate all the base objects including object, and nobody wants to do new java.lang.Object();.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote