DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    2

    Help newbie,please!

    Hi,My name is Nan,I am C/C++ programmer and now I am going to learn java,but I have a litlle problem.Can you help me find out functions in java or is there another "things" that can compare functions.
    Like I want a make calculator,which will have function calc() to calculate expressions.

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    Java is very closesly related to C++, it was designed that way. Functions work pretty much the same way that they do in C++, but the thing is that everything has to be in a class. So to start you calculator example you might start with something like:
    Code:
    public class Calculator {
      public int clac(String expr) {
        // ... Code for evaluating goes here
      }
      public static void main(String[] argv) {
        System.out.println(new Calculator().calc(argv[0]));
      }
    }
    If you want to learn Java, I would look at some of the tutorials online. Sun has some decent ones: http://java.sun.com/docs/books/tutorial/.

    I hope this helps.
    ~evlich

  3. #3
    Join Date
    Jun 2005
    Location
    Chennai
    Posts
    10

    use java.lang.Math

    If you want to make use of the Java built in functions. Then try the class

    "java.lang.Math" , in which a set of mathematical functions are there.

    Cheers

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links