@ruchira ur solution it self is best.But i think if it is only about integer and a string we can do it in much easy and simple way..
class B {
public String myfun() {
int a=2; //Integer .. you could use scanner or pass parameters ..i have simply assigned
String b="hi"; //String
return Integer.toString(a)+","+b; //returnig string and int with "," in middle
}
}
class A {
public static void main(String args[]){
B obj=new B(); // obj of class B with myfun() method
String returned[]=obj.myfun().split(",");
//splitting integer and string values with "," and storing them in array
int b1=Integer.parseInt(returned[0]); //converting first value in array to integer.
System.out.println(returned[0]); //printing integer
System.out.println(returned[1]); //printing String
}
}
i hope it was useful.. :)