java Functions are most strong to handle the operations with global variables and arguments passed to it. the variables defined inside the java functions are always local and are only available inside function only. Function can return any value of the class type. We can consider data type int, float, String etc as a Class type. In function one can return Object typed java.
Here is one simple function illustrated for concept of java array.
public void setStudentArray(){
for(int i=0;i<num;i++){
HasStudent student=new HasStudent();
System.out.println("======***********========");
student.name=setName();
student.Address=setAddress();
student.rollNo=setRoll();
stdArray[i]=student;
System.out.println("======***********========");
}
}
In this function there is no return type and no argument. only local and global variables available inside the functions are processed with this function and are available when callng the function
we can declare function with the return type as follows:
(Access_Specifier) (ClassName) functionName(arguments.
class definintions;
processing of local and global datas.
return(Object of class);
}
No comments:
Post a Comment