Check length on a integer variable

I have a declared
int IntLength=1234;how can i check the length on this, how many letters there are?
you can use .length on string variables, but cant find out how do make it work on a integer.
sincerely h

as the previous poster said... maybe something like...
int i = 1234;
String s = ""+i;
System.out.println( "length = " + s.length() );or the illegible version
System.out.println( "length = " + ((""+1234).length()) );

Similar Messages

  • This test checks whether the length of the environment variable "PATH" does not exceed the recommended length.

    when i am going to Install 11gR2 then thsi error shows how to solve it plz give me guidance
    This test checks whether the length of the environment variable "PATH" does not exceed the recommended length.
    Expected Value:     1023
    Actual Value:          0

    HELLO iSHAN SHAH
    JUST EXPLAIN US YOUR PROBLEM IN DEPTH.
    TELL US YOUR HARDWARE AND SOFTWARE CONFIGURATION.
    ALSO TELL US IN WHICH STEP OF INSTALLATION , THIS ERROR RAISED.
    THANKS
    HARSH SHAH

  • Assign hexadecimal value to an Integer variable preceding with zero

    hi
    i need to pass an hexadecimal value, preceding with zero (0).
    like 0775
    the above hexadecimal value should be assigned to an integer variable. While i am trying to assign it, the output could be truncate the preceding zero value. Is it possible to do my requirement without truncating the preceding zero.?
    Edited by: sasi on Jul 23, 2012 7:09 PM

    I agree on that, this can not be carried out the way you explained.
    Either you store the hexadecimal value as a string, and convert it before arithmetic operations:
    int number = Integer.parseInt("0775", 16);
    Or you store it as an integer (no leading zero) and convert it to string as you display it:
    int number = 0x0775;
    System.out.printf("%1$04x", number);

  • Please help with integer variable matching frame numbers

    hi :-) , could someone please hepl a newbie ?
    I am trying to write a short AS3 script in CS4 that allows me to step backwards and forwards  through an animation.
    I have a stop button a play button , rewind button and a forward button.
    the buttons work ok apart from when I hit the rewind button sometimes it jumps to the start of the timeline rather than just step back a frame at a time.
    when I use the stop button and the timeline stops where it is, the rewind button steps back as required. but, if the rewind button is clicked first it jumps to the start of the timeline, I know the theory as to why I cant get this to work.  I need to know how to increment an integer variable (counter) to increment as the animation playes. i.e. the counter variable to match the frame number.  below is the code I have, could someone please tell me how to match an integer variable to the current frame and tell me where to insert the line of code on the listing. I have added a dummy line or psuedo line of code to show what I am trying to do, but the syntax is wrong .
    var counter = 1;
    gotoAndStop(counter);
    function setupevents()
        buttonplay.addEventListener(MouseEvent.CLICK, playbutton);
        buttonstop.addEventListener(MouseEvent.CLICK, stopbutton);
        buttonrewind.addEventListener(MouseEvent.CLICK, rewindbutton);
        buttonforward.addEventListener(MouseEvent.CLICK, forwardbutton);
    setupevents();
    //this is the dummy or psuedo line of code i mentioned in the question above....
    counter = frame;
    //function to play the movie
    function playbutton(event:MouseEvent)
        play();
    //function to stop the movie using the stop button
    function stopbutton(event:MouseEvent)
        stop();
    //function to step backwards through movie using the rewind button
    function rewindbutton(event:MouseEvent)
        if(counter > 1)
            counter = counter - 1
        gotoAndStop(counter);
    //function to step forward through movie using the forward button. I have used the value of 60 as this is the amount of frames in the timeline
    //I dont know if this is correct way to do things or not
    function forwardbutton(event:MouseEvent)
        if(counter < 60)
            counter = counter + 1
        gotoAndStop(counter);
    I know the code is rough and basic but any help would be greatly appreciated, I have tried to attach the .fla file for anyone who needs more info on this.  But this webpage returned an error "The content type of this attachment is not allowed."
    Auldy66

    var counter = 1;
    gotoAndStop(counter);
    function setupevents()
        buttonplay.addEventListener(MouseEvent.CLICK, playbutton);
        buttonstop.addEventListener(MouseEvent.CLICK, stopbutton);
        buttonrewind.addEventListener(MouseEvent.CLICK, rewindbutton);
        buttonforward.addEventListener(MouseEvent.CLICK, forwardbutton);
    setupevents();
    //this is the dummy or psuedo line of code i mentioned in the question above....
    counter = frame;
    //function to play the movie
    function playbutton(event:MouseEvent)
        play();
    //function to stop the movie using the stop button
    function stopbutton(event:MouseEvent)
        stop();
    //function to step backwards through movie using the rewind button
    function rewindbutton(event:MouseEvent)
    prevFrame();
    function forwardbutton(event:MouseEvent)
    nextFrame();

  • How use integer variable as object in query

    sir how use integer variable as object in query
    see my code
    Integer currentssgg = new Integer(tt.getValue().toString()); no error
    //yy.setValue(currentss); no error
    //yy.setValue(new Integer(tt.getValue().toString())); no eror
    getSessionBean1().getTripRowSet().setObject(1,currentssgg); giv error
    tripDataProvider.refresh();
    and how use string variable same as method
    please give me idea how use integer variable as object in query
    thank's
    aamir

    >> var mnu = 'menu1';
    this[mnu].onRollOver = function(){
    <<
    Close, but it needs to be like this:
    var mnu = 1;
    this["menu" + mnu].onRollOver = function(){
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Reflection/Introspection: how to check simple vs complex inst variables?

    Hi developers,
    I need to traverse an object tree (xml based generation) and check whether underlying objects (e.g. instance variables) are primitive types/wrappers (int, Integer, short, Short) or complex types (e.g. Employee, Customer, ...). The purpose is to allow users to directly enter data in primitive fields and to expand complex nodes.
    I am using introspection/reflection.
    Until now I have come out with the following code:
    public class MyTest {
        public static final List<Class> primitiveList;
        static {
         primitiveList = new ArrayList<Class>();
         primitiveList.add(String.class);
         primitiveList.add(Integer.class);
         primitiveList.add(Date.class);
         primitiveList.add(Short.class);
         primitiveList.add(Double.class);
         primitiveList.add(Long.class);
        public static boolean isPrimitive(Object obj) {
         return primitiveList.contains(obj.getClass());
        public static void main(String[] arg){
         String foo = "foo";
         System.out.println(isPrimitive(foo)?"primitive":"complex");
    }It looks very low-level to me... Can anyone please suggest a better way to do this?
    Thanks and kind regards

    My guess is that you will have to write most of this yourself and that it will be custom code.
    However, take a look at nakedobjects.org (no, it's not an adult site). It allows users to do exactly what you are trying (or at least partially what you are trying).
    You can optimize your method slightly by using common classes (e.g., Number, CharacterSequence, etc.) but then will have to use Class#isAssignableFrom on each.
    - Saish

  • The length of an integer

    Hello.
    Just for couriosity I'd like to calculate the length of an int and by that I mean return the number of digits.
    I know how to do this 'manually', but is there a method somewhere that looks a bit like this:
    object.calcInt(47653);//returns 5Thanks in advance

    Interesting. Nobody likes the log method even though it is 30% faster.
    public class Garbage
        public static final int FIRST_INT = Integer.MAX_VALUE - 10000;
        public static final int LAST_INT  = Integer.MAX_VALUE;
        public static final int TESTS = 1000;
        public static void main(String args[])
            long divideTestTime = 0;
            long stringTestTime = 0;
            long logTestTime = 0;
            DivideTest divideTest = new DivideTest();
            StringTest stringTest = new StringTest();
            LogTest logTest = new LogTest();
            for (int i = 0; i < TESTS; i++)
                    divideTestTime += runTest(divideTest);
                    stringTestTime += runTest(stringTest);
                    logTestTime += runTest(logTest);
            System.out.println("Divide-test Time: " + divideTestTime);
            System.out.println("String-test Time: " + stringTestTime);
            System.out.println("Log-test Time: " + logTestTime);
        public static long runTest(Test test)
            long start = System.currentTimeMillis();
            for (int i = FIRST_INT; i < LAST_INT; i++)
                    test.lengthOf(i);
            return System.currentTimeMillis() - start;
    interface Test {
        public int lengthOf(int i);
    class DivideTest implements Test {
        public int lengthOf(int i) {
            int size = 0;
            do {
                size++;
                i /= 10;
            } while(i > 0);
            return size;
    class StringTest implements Test {
        public int lengthOf(int i) {
            return String.valueOf(i).length();
    class LogTest implements Test
        private static final double l210 = Math.log(10);
        public int lengthOf(int i) {
            return (int)(1 + (Math.log(0.5 + i) / l210));
    }

  • How to check length of string attribute(from viewobject) on jspx ?

    Hi,
    JDEV : 11.1.1.4
    I am using carousel component inside that i am using Descrip attribute to show the content on carousel item,
    Now i want to display a more link , whenever the length of Descrip is greater than 150 characters.
    Currently from backing bean i am setting the chklength property based on length to true or false but the problem is i need to set a partial target
    and because of that my carousel component i getting refreshed every time.. is there any way to check the length in jspx page itself inside the vissible property
    this is my code
    <af:outputText value="#{item.bindings.Descrip.inputValue}"
                                                             id="ot49"/>
                                               <af:commandImageLink text="more.." id="moreid" shortDesc="click to see more.."
                                                                     visible="#{pageFlowScope.chklength}">
                                                <af:showPopupBehavior popupId="::p1"/>
                                                </af:commandImageLink>              thanks
    Gopinath

    i have added taglib like this,
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    but its showing error on below expression
    visible="${fn:length(item.bindings.Descrip.inputValue) > 150}"
    error : BooleanSimnpleTypeConvertor:"${fn:length(item.bindings.Descrip.inputValue) > 150}" cannot be converted to this type

  • How to check a numuric. in a variable.

    Hi friends.
    I want to check one variable type Numc, if it contains number(). I have to raise the message for that. it contanis numeric.
    Please help me.
    with regards.
    Koteswar.

    Hi vk rao,
                   Try this.........
    data:
       w_num TYPE n.
    IF w_num CA '0123456789'
       MESSAGE 'Variable contains some numeric values' TYPE 'W'.
    ELSE.
       MESSAGE 'Variable doesn't contain some numeric values' TYPE 'W'.
    ENDIF.
    Reward,if helps.......
    Bye,
    V.Raghevender.
    Message was edited by:
            Raghavender Vadakattu

  • How to check a char. in a variable.

    Hi friends.
    I want to check one variable type Numc, if it contains alphabet(either capital or small). I have to raise the message for that.
    Please help me.
    with regards.
    Koteswar.

    Hi,
    Use the function module NUMERIC_CHECK.
    Exx
    DATA: S_STRING TYPE STRING.
    DATA: DDIC_TYPE TYPE DD01V-DATATYPE.
    CALL FUNCTION 'NUMERIC_CHECK'
       EXPORTING
         STRING_IN = S_STRING
       IMPORTING
          STRING_OUT = S_STRING
          HTYPE          = DDIC_TYPE.
    IF HTYPE = 'NUMC'.
    ***OK..
    ELSE.
    ***NOT OK..
    ENDIF.
    Thanks,
    Naren

  • Check that at least one variable is set

    I have 10 variables/parameters and i want to ensure that at least one of those is not empty/null. What is the best way to check that?
    Example of parameters:
    p_item_category1 varchar2,
    p_item_category2 varchar2,
    p_item_category3 varchar2,
    p_item_category4 varchar2,
    p_item_category5 varchar2,
    p_item_category6 varchar2,
    p_item_category7 varchar2,
    p_item_category8 varchar2,
    p_item_category9 varchar2,
    p_item_category10 varchar2
    Should the best way be as:
    if (p1 is not null) or
    (p2 is not null) or
    (p10 is not null) then
    --at least one parameter has value, ok,
    else
    --all parameters are empty, give error message
    This code looks long, is there cleaner* better way to achieve the same?
    Maybe there is a system function "AtLeastOnInSetIsNotNull", something like
    if AtLeastOnInSetIsNotNull(p1,p2,..,p10) then...
    That would be more handful.

    Seems like coalesce is even better, thx.
    declare
    p1 varchar2(1) := null;
    begin
    dbms_output.PUT_LINE(coalesce(null,'1',null,'2'));-- outputs: 1
    if coalesce(null,p1,null,null) is null then
    dbms_output.PUT_LINE('all parameters are null');--outputs: all parameters are null
    end if;
    end;

  • Defining text and integer variables??

    I found this in some code:
    var num = 0, txt = "bo";
    I guess it could also have been written as:
    var num = 0,
    txt = "bo";
    Why is it allowed to define an integer by just using "," and when you define a text variable you use ";"

    The code you are looking at would be javascript, not java.
    Despite the name, the two are definitely NOT the same thing.
    Why is it allowed to define an integer by just using "," and when you define a text
    variable you use ";" You are misunderstanding the syntax.
    The semicolon ';' completes a statement
    the comma was just separating multiple variable declarations on the same line.
    It could just as easily have been
    var txt="bo", num=0;
    var a=42, b=69, c=666;
    Just to reiterate this is NOT valid java code. Java does not use the "var" keyword.
    It is javascript, which means it can do pretty much whatever it likes ;-)

  • Check number sequence - previous record variable

    Post Author: rmhogan
    CA Forum: Formula
    I am trying to highlight a record that is out of number sequence with the previous record.  I am guessing that I need to create 2 variables (one for the current number and one for the previous number).  I cannot seem to get this to work.
    Any help would be appriciated.
    Example ....
    Check Number
    016000123
    016000124
    016000126 <--- out of sequence (I want to highlight this detail line)
    016000127

    Post Author: rmhogan
    CA Forum: Formula
    Thanks so much.  However, I am getting a error saying  ... "The formula result must be a number".  The fields are strings in the database, however I have converted the to numbers in a formula  &#91;tonumber() function&#93;.
    Any ideas.

  • How to transform a byte[] variable to a Integer variable?

    Can anybody do me a favor to tell me how to trasform a byte[]variable to a Integer or String variable?
    Thank you very much

    To transform a bytearray to a string is simple:
    String s = new String(byteArray);Transforming an bytearray to an Integer isn't that simple... I don't know the best way to do it. But one way is to transform it to a String and then:
    Integer i = new Integer(new String(byteArray));//David

  • Checking length of a field in a table

    Hi,
    How can i use STRLEN to check the length of a field in a table... lets say i have to chek the length of the field VBELN in the table VBAK.
    I will reward all the useful answers.
    Thanks,
    Mohit.

    Hi Mohit,
    I have a doubt: do you want to compute the length of a value stored in a field, or to compute the length of the definition of that field?
    1. In the first case, just make sure that the field is filled OK, then compute
    l_length = strlen( vbak-vbeln ).
    2. In the second case, you will have to compute
    describe field vbak-vbeln length l_length.
    For example, if VBAK-VBELN = '1234', then the first case will result 4, but the second case will result 10.
    I hope this helps. Best regards,
    Alvaro

Maybe you are looking for

  • Download other templates?

    Hey everyone!! I have this big project I have to present in the beginning of April for the french baccalaureate (TPE), so I want to make a magazine and there's not enough templates in Newsletters section. Plus, I have trouble in making templates of m

  • Problem with commas in user settings in 4.0, WS

    There seems to be a problem returning user settings with GetUserSettings. The setting that contains a comma is being chopped. Dim ptSettings, ptUserSettings Set ptSettings = Server.CreateObject("GSServices.Settings") Set ptUserSettings = ptSettings.G

  • Changing passwords of oracle users

    Dear all I wander is there any problem if changing password of oracle users SAPOWNER, system,sys . (I guess command for that is brconnect -u system/<password> -f chpass -o <sapowner> -p <password> ). What about sys and system. (I hope that after chan

  • IPhoto on iPad how to preview book project

    How can I on my iPad preview an iPhoto completed project book? 

  • Can't reopen iPhoto after installing update on MacBook Pro.

    I installed an update for iPhoto yesterday and now find I cannot reopen it. When trying to install, it gets to 50% of step 2 and then quits. Is there any way I can save my photographs, which aren't backed up anywhere other than iPhoto?