Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: passing boolean value issue

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default passing boolean value issue

    Hi, i am new to java.I was having a two java files inside same package name.

    "first file"

    public class Send
    {
    static int a=1;
    static int b=1;
    public static void main(String args[])
    {
    if(a==b)
    {
    Get.getit = true;
    }
    }
    }


    "second file"


    public class Get
    {
    static boolean getit=false;
    String a = "hai";
    {
    if(getit)
    {
    System.out.println(a);
    }
    }
    }

    How can i pass the value from send.java to get.java.
    Last edited by tr_tech; June 16th, 2011 at 09:08 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: passing boolean value issue

    Pass a reference to the object

    public class ClassA{
        private int value;
     
        public ClassA(int v){
            this.value = v;
        }
        public int getValue(){
            return value;
        }
    }
     
    public class ClassB{
        private ClassA classa;
        public ClassB(ClassA a){
            classa = a;
        }
        public void doSomething(){
            int value = classa.getValue();
        }
    }

Similar Threads

  1. Boolean method returning a boolean value
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 10:56 AM
  2. Some help with boolean
    By JPetroSS in forum Java Theory & Questions
    Replies: 3
    Last Post: November 2nd, 2010, 05:38 AM
  3. ArrayList Boolean Issue
    By kite98765 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 8th, 2010, 08:15 AM
  4. Passing in more than one flag
    By anon181 in forum Loops & Control Statements
    Replies: 3
    Last Post: February 2nd, 2010, 06:37 AM
  5. [SOLVED] Modification of Boolean function in Java program
    By lotus in forum Java SE APIs
    Replies: 4
    Last Post: July 10th, 2009, 10:15 AM

Tags for this Thread