java - What does it mean to call a class as a function? -


i'm porting code java (i know nothing language) c. fact java c-like language, have no problem in converting statements. have no idea parts of code mean. calls java class function , pass parameter:

assume classes be:

public class foo {      public foo(typex x) { //etc } }  public class baa {     public baa(typex x) { //etc } } 

from class it's called as: new foo(baa())

what mean?

this wrong ! new foo(baa())

you cannot in java, instead need

new foo(new baa().bar()) .  

this means first create reference (object) of baa , call bar() method of reference. remember new keyword in java create new reference out of class. calls constructor method of class , allocates memory reference.

further in above case passes whatever returned bar() method argument foo class , in turn create reference of foo class too.

this start : [1]: http://docs.oracle.com/javase/tutorial/java/javaoo/index.html


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -