java - What instance of the Object is this method returning? -
i have written below method need find instance of object returned.also need check if json type or other type returned method work?
public class dynamicobject { public static void main(string[] args) { // todo auto-generated method stub dynamicobject obj = new dynamicobject(); if(obj.testobj() instanceof string) system.out.println("string"); else if (obj.testobj() instanceof array) system.out.println("integer array"); else if (obj.testobj() instanceof integer) system.out.println("integer"); } private object testobj(){ boolean test = false; string s= new string("test"); integer in[] = {1,2,3,4,5}; if(test){ return s; }else{ return in; } } } what shall instance of case.if run console doesn't show anything.
instanceof should integer[]
else if (obj.testobj() instanceof integer[]) system.out.println("integer array");
Comments
Post a Comment