Beginners question

I have 2 java-files (classes), in the 1st one I want to declare a class with some variables. These variables must be initialised with some values. After that, I want to call (from the 1st class) the class in the 2nd file which needs the variables from the first class.

Because I want to use a block of variables containing e.g. 25 variabels, I want to parse just a reference or something to the 2nd class.

no problem because as virex clearly shows, you can access thing from any other java file

let me explain the code you seem not to grab the concept
[i did a bit of modification becuase i think making a new instance is not necessary for the purpose, any way both codes will work]

class with variables you want or the your first class file:

Code:

//note that the class is public, so this class is visible to all other classes
public class MathVirxen{
public static final double PI=3.1415926;
public static final double sin30=0.5;
public static final double cos60=0.5;
//Note that all the variables are also declared as public, so any class outside see and can access these
// I made them all static so then an instance of the class is not necessary for another class to access the variables
// the final modifier is not a must but depending on the situation, you would like the values to be constant or you can accidently change there values
}

then donot make them static because static means they are not instance related but it is related to the class
i think this would be something you are looking for

Code:

public class Reuser{
public int someNum = 10;
private String name;
public double sum;
//you dont have static ones anymore because static ones are not changedd with instance
//you can use both public and private and the difference is that you cannot directly call the private ones, i'll show it in the other code block
public Reuser(String str){
name = str;
}
//This is a class constructor, as i cannot directly assign value to the private variable, i use the constructor to do that and even you can use a setter method to do this
public void setName(String str){
name = str;
}
//To get the value of the method you use a getter
public String getName(){
return name;
}
}

A class that uses multiple of this

Code:

class User{
public static void main(String... args){
Reuser user1 = new Reuser("Giving the name");
Reuser user2 = new Reuser("You always have to set this as there's no defualt constructor now");
user1.setName("Changing the name");
System.out.println(user1.someNum); //calling a public variable no prob;
user1.sum = 1221.31361d; //setting a public variable so no prob
System.out.println(user1.sum);
//The below code IS COMMENTED BECAUSE IT IS WRONG
// user1.name = "You cannot access private variable like this";
// System.out.println("Not even like this :" + user1.name);
System.out.println(user1.getName()); //you can use the getter method to recieve the value
}
}

I hpe you get that, but please tell me for any erros in the code because i didnt compile the code beforehand

----------------------
So far so good, works perfect !
Maybe I do something wrong, check the above things and if it's wrong, please tell us what's wrong
and how it must be fixed ;-)

BUT: I have 2 problems now:

1) Everything works ok when I build and RUN the program inside NetBeans.
But it starts a bit slow, not sure why ? Also parts of the program are a bit slow the first time, for
example if I open a new dialog and close it and open it again. First time it's slow, next times it's fast.

2) When I RUN the builded RUNTIME version (myprogram.jar) on a Windows 7 (32bit, 3Ghz) computer,
so not inside the NetBeans environment, it works but a part of the program doesn't work at all.
(some selection to open a new Dialog, it doesn't open the new Dialog).
Don't understand how this is possible ?

here you create the datablok object inside the function and return it, usually returning local members like objects is not bad, because once the function is over usually the things created with in the function are eligible for gc()
but in this case they will be tied again for a reference, so for me the situation is a bit tricky

better if you define the datablok out of the boudary and return it from the function