Results 1 to 2 of 2
  1. #1
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Question How to separate return value ??

    Hi,

    From the below code if i want to separate the return value and print separately what should i do ?
    Java Code:
    public class TestValue{
    String print;
    
    public String calculate(double a, double b){
    double add=a+b;
    double subtract=a-b;
    double multiply=a*b;
    double division=a/b;
    
    print = "Total="+add+"\nSubtract="+subtract+"\nMultiply="+multiply+"\nDivision="+division ;
    
    return print ;
    
    }
    
    public static void main(String[] args) {
    TestValue tv=new TestValue();
    String st=tv.calculate(20,10);
    
    System.out.print(tv);
    }
    i mean i just want to print out subtract only or multiply only without changing the String 'print'

    Is it possible ??
    what we are thinking, it might not be true

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    12

    Default

    You yould use String.split() to get the different parts of print.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Replies: 3
    Last Post: 07-10-2015, 03:09 PM
  2. How can my applet read from a separate .jar?
    By DenniGa in forum Java Applets
    Replies: 2
    Last Post: 03-27-2009, 04:34 PM
  3. Should I separate my code into separate files?
    By Inks in forum New To Java
    Replies: 0
    Last Post: 03-26-2009, 01:12 AM
  4. combining two separate codes into one
    By jaiminparikh in forum Advanced Java
    Replies: 22
    Last Post: 02-18-2009, 06:35 PM
  5. Hash table with separate chaining
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 09:42 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
  •