Home > Back-end >  Why "String: : toUpperCase" can be normal use?
Why "String: : toUpperCase" can be normal use?

Time:04-15



Function F1=String: : toUpperCase;
System. The out. Println (f1. Apply (" ab "));

Function F0=String: : matches;
System. The out. Println (f0. Apply (" aa "));

In the String class toUpperCase and matches are not static method, is what "String: : toUpperCase" can be normal use?

CodePudding user response:

: : it is a layer of syntactic sugar, with a static method it doesn't matter, it is very easy to understand
 
Function F1=String: : toUpperCase;
System. The out. Println (f1. Apply (" ab "));

The actual equivalent to
 
System. The out. Println (" ab ". ToLowerCase ());

But the second function
 
Function F0=String: : matches;
System. The out. Println (f0. Apply (" aa "));

What can you is equivalent to, not corresponding parameters
 
System. Out.println (" aa ". Matches (???? ));

It is clear that this way, you can't use: : to write

CodePudding user response:

Is: : only three on parameterless method? Where to find: the implementation of the logic (source)?
  • Related