Java Object Type Case cast(Object x)

Here you can find the source of cast(Object x)

Description

Use this function to eliminate silly "unchecked" warnings that cannot be fixed in Java otherwise.

License

Apache License

Parameter

Parameter Description
x value to cast
T type to cast to

Return

same value

Declaration

@SuppressWarnings("unchecked")
static <T> T cast(Object x) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  w w  w . ja  v  a 2 s  .  c  o  m
     * Use this function to eliminate silly "unchecked" warnings that cannot be fixed in Java otherwise.
     *
     * @param x   value to cast
     * @param <T> type to cast to
     * @return same value
     */
    @SuppressWarnings("unchecked")
    static <T> T cast(Object x) {
        return (T) x;
    }
}

Related

  1. cast(Object object, Class targetClass)
  2. cast(Object source)
  3. cast(Object val, Class type)
  4. cast(Object value, String sqlType)
  5. cast(Object x)
  6. cast(Object[] parameters, Class[] types)
  7. cast(String type)
  8. castAndThrow(Throwable e)
  9. castArray(Object[] array, T[] targetArray)