Submit Java Code

Home Forums Java Submit Java Code

This topic contains 1 reply, has 2 voices, and was last updated by  srinadh 2 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7924

    daryl
    Participant

    Hi,

    I am looking for example Java code that I can use in this web site. If you have any code that you believe I could use as examples, Please submit them here.

    Thx,

    • This topic was modified 3 years, 6 months ago by  daryl.
    #295216

    srinadh
    Participant

    Hi,

    Here is the sample code on type conversion in Java Programming.

    class TypeConversion
    {
    public static void main(String arg[])
    {
    byte b = 50;
    short s = 4125;
    int i = 800000;
    long l = 107343L;

    s = b; // LINE A
    i = s; // LINE B
    l = i; // LINE C

    float f = 25.0f;
    double d = 327.98;

    f = i;
    d = f;

    System.out.println(“b = ” + b );
    System.out.println(“s = ” + s );
    System.out.println(“i = ” + i );
    System.out.println(“l = ” + l );
    System.out.println(“d = ” + d );
    System.out.println(“f = ” + f );

    }
    }

    The output of an above Java Programming code is,

    b = 50
    s = 50
    i = 50
    l = 50
    d = 50.0
    f = 50.0

    • This reply was modified 2 years ago by  srinadh.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.