How to.. "access-back" class members?

Category: Latest Asked Questions    |    5 views    |    Add a Comment
Hi,
I’m sorry for making the question unclear, but my English is not good.
I will try to explain it:

class test0{
        test1 t1 = new test1();
        public static void main(String args[]){
                new test0();
        }
        public test0(){                
                t1.displaymsg1();
                t1.callDisplaymsg0();
        }
        public void displaymsg0(){
                System.out.println("Successfully linked to test0 class");
        }
}

class test1{
        test0 t0 = new test0();
        public void callDisplaymsg0(){
                t0.displaymsg0();
        }
        public void displaymsg1(){
                System.out.println("Successfully linked to test1 class");
        }
}

Class test0 can "new test1()", and access its members. But when I try to "new test0()" in class test1, to access class test0’s members, it floods the screen with many lines of errors like:
at test1.<init>(test0.java:16)
at test0.<init>(test0.java:2)
at test1.<init>(test0.java:16)
at test0.<init>(test0.java:2)

and I could not read the first lines of the error, so I don’t know what the error is..

So my question is:
How to access class test0 members from class test1?

Thanks a lot in advance!

Share/Save/Bookmark

 

need open sourse cell phone code

Category: Latest Asked Questions    |    2 views    |    Add a Comment
is there any place i can find some Open Source cell phone code written in Java, where i can use a IDE and check it out and maybe even test it on my phone?

Share/Save/Bookmark

 

Help with Sorts

Category: Latest Asked Questions    |    4 views    |    Add a Comment
I’m trying to do selection sort for objects…But it wont work, please help. We were told to change the first one to do objects. Any help appreciated

public static void selectionSort (int[] numbers)
   {
      int min, temp;

      for (int index = 0; index < numbers.length-1; index++)
      {
         min = index;
         for (int scan = index+1; scan < numbers.length; scan++)
            if (numbers[scan] < numbers[min])
               min = scan;

         // Swap the values
         temp = numbers[min];
         numbers[min] = numbers[index];
         numbers[index] = temp;
      }
   }

   public static void selectionSort (Comparable[] objects)
   {
      int min;
              Comparable temp;

      for (int index = 0; index < objects.length-1; index++)
      {
         min = index;
         for (int scan = index+1; scan < objects.length; scan++)
            if (objects[min].compareTo(objects[scan]))
               min = scan;

         // Swap the values
         temp = objects[min];
         objects[min] = objects[index];
         objects[index] = temp;
      }
   }

Share/Save/Bookmark

 

why long variable is taking integer value?

Category: Latest Asked Questions    |    3 views    |    Add a Comment
i have written the following code and it is not executing due to the following error
dec.java:7:integer number is too large :10000000000

code

import java.util.*;
class dec{
public static void main(String args[]){
long dig,store,use,temp,temp1,end;
int count=0,count1=0,ch;
use=1000000000;
end=10000000000;
while(use<end){
dig=use;
for(int i=0;i<10;i++){
temp=dig%10;
dig=dig/10;
ch=(10-i)%10;

store=use;
for(int k=0;k<10;k++){

temp1=store%10;
store=store/10;
if(temp1==ch)
count++;
}
if(count!=temp)
break;
else count1++;
}
if(count1==10){
System.out.println("the number is "+use);
break;
}
use++;
}

}
}

i can’t understand why long variable is taking integer value.

Share/Save/Bookmark