Click here to Skip to main content
16,017,241 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

I'm new to jave and trying to pass a variable from one class file so I can use it in another one.

here's the code

This is in a class file named SkyMountain, what I'm trying to do is use this as a scaler for all images and positions but since I'm new and still learning this one is giving me a headache, and I'm reading a java book but still learning.

Java
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {		
	super.onSurfaceChanged(holder, format, width, height);	
	int samsScaler = width / 1024;
}


I'm trying to pass this (int samsScaler) into another java class file named Mountain and use it to scale an image I'm sure this is simple for those who know java well but for me a noob in this it isn't yet.
Posted
Updated 20-Mar-11 17:46pm
v2

You do not pass any data to class, you pass it to class instance. Do you know what properties and methods are for? This is indeed a matter of learning. My advice is: don't ask question here at CodeProject: you're not ready yet, so it would be just a waste of time.

Use the following directions (first reference in my advices posted in Answer of different Question):
I have a problem with my program. Please help![^]
Knowledge base Q209354.

This is very sobering: http://norvig.com/21-days.html[^].

—SA
 
Share this answer
 
Comments
Albin Abel 20-Mar-11 23:10pm    
Good Answer. My 5
Sergey Alexandrovich Kryukov 20-Mar-11 23:17pm    
Thank you, Albin.
--SA
wow typical I guess for noobs looking for help.
So I guess anyone wanting to learn (hence questions) is not allowed if they ask they get insulted and told not to ask.
So yoda when is one ready to ask questions on things they do not know yet?
Just to give you some past experiences, I used to program in C C++ flash PHP but its been years since I touch coding and forgot almost everything so its like learning from scratch again for me.
When I first started learning C++ I used to ask questions to learn more as I found out you can learn a lot quicker from other programmers than from books and usually teachers (which at the time I was using all 3).
To my dismay I found the programmers the rudest to try and find out more information from and wondered why they even bothered to answer at all except to throw the odd insult at noobs which only discouraged them and frustrated them even more from learning.
Once I did learn flash and php thanks to a great community of programmers and a few books, I became a technical reviewer for those books within a year, major thanks for my quick learning goes the community of good people willing to help out noobs like I was and am now in java.
In turn I helped out a lot of other folks to learn quicker with only one requirement which was to help others as well and don't pull the attitude so many have towards noobs and remember they were one once also.
So yes I will not ask anymore here as its useless to any noob wanting to find help.
I will learn this one way or another (if only from books then from books)
Its just nice to make quicker sense and more sense from others that actually know what there doing.
Hopefully there is a community that accepts noobs, this place is not one obviously.
Sorry for bothering your intellegece lol.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900