Results 1 to 3 of 3
  1. #1
    greenco is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default [SOLVED] Code Explaination Help

    I am trying to learn Java and I have been looking at a lot of code samples. I ran across this and I hope that some kind soul will explain the symbols and their meanings.

    Java Code:
    public class BasicMathDemo {
        public static void main(String[] args) {
            double a = -191.635;
            double b = 43.74;
            int c = 16, d = 45;
    
            System.out.printf("The absolute value of %.3f is %.3f%n", a, Math.abs(a));
            System.out.printf("The ceiling of %.2f is %.0f%n", b, Math.ceil(b));
    	System.out.printf("The floor of %.2f is %.0f%n", b, Math.floor(b));
            System.out.printf("The rint of %.2f is %.0f%n", b, Math.rint(b));
            System.out.printf("The max of %d and %d is %d%n",c, d, Math.max(c, d));
            System.out.printf("The min of of %d and %d is %d%n",c, d, Math.min(c, d));
    The code in the "printf" statements do not mean much to me and it would help me a lot if you could explain a couple of them to me as if I was "12 year old".
    Thanks

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Come on...

    What you are showing is the sample that the Sun Tutorials gives for explaining the math class. Look one topic before (Formatting Numeric print output) and it's all explained there. Just in case you have trouble finding it, here's the link:

    Formatting Numeric Print Output (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    greenco is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    Thanks for the link!!!
    Now I will try and understand what all it is explaining.

Similar Threads

  1. log in code
    By kevN in forum New To Java
    Replies: 0
    Last Post: 11-17-2008, 10:05 AM
  2. Tiles process flow explaination needed...
    By abhishek paul in forum Web Frameworks
    Replies: 0
    Last Post: 04-29-2008, 04:02 PM
  3. code for £20;-)
    By sparky2003752 in forum JCreator
    Replies: 0
    Last Post: 04-17-2008, 05:31 PM
  4. I need help fixing my code.. or non code?
    By MrHuggykins in forum New To Java
    Replies: 1
    Last Post: 03-19-2008, 10:12 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •