Link to home
Start Free TrialLog in
Avatar of maerskssc
maerskssc

asked on

Length Sintaxis in Java

What is the sintaxis for the function lenght in Java, could you pls provide an example. What I really need is to determine how many characters are in variable.Tks in advance
ASKER CERTIFIED SOLUTION
Avatar of nesnemis
nesnemis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi maerskssc,

import java.lang.reflection;

do this function

public void displayClassFieldName(Class theClass)
{
    Field[] fields = theClass.getDeclaredFields();
    for(int i = 0; i < fields.length ; i++ )
    {
      String fieldName = fields[i].getName();
      System.out.println(fieldName.length());
    }

}

call like this:
displayClassFieldName(myObject.getClass())


Cheers!