get String from Object - Java java.lang

Java examples for java.lang:String Format

Description

get String from Object

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        Object curObject = "java2s.com";
        System.out.println(getString(curObject));
    }//from   www.  j  ava  2 s  . c om

    public static String getString(Object curObject) {
        if (null == curObject) {
            throw new NullPointerException("The input object is null.");
        } else {
            return curObject.toString();
        }
    }
}

Related Tutorials