将变量传递到另一个文件时出现问题 [英] problem passing variables to another file

查看:73
本文介绍了将变量传递到另一个文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我是jave的新手,正尝试从一个类文件传递一个变量,以便可以在另一个文件中使用它.

这是代码

这是在一个名为SkyMountain的类文件中,我想做的就是将它用作所有图像和位置的缩放器,但是由于我是新手并且仍然在学习它,这让我很头疼,我''我正在读一本Java书籍,但仍在学习中.

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.

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



我正在尝试将此(int samsScaler)传递到另一个名为Mountain的Java类文件中,并使用它来缩放图像.我确信这对于那些熟悉Java的人来说很简单,但对我来说这是一个菜鸟.尚未.



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.

推荐答案

您没有将任何数据传递给类,而是将其传递给类 instance .您知道属性方法是做什么的吗?这确实是一个学习的问题.我的建议是:不要在CodeProject上提问:您还没有准备好,所以这只是浪费时间.

请遵循以下指示(在不同问题的答案"中发布的建议中的第一参考):
我的程序有问题.请帮忙! [知识库Q209354 .

这非常清醒: http://norvig.com/21-days.html [
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


哇,我想这是菜鸟们在寻求帮助的典型例子.
因此,我想任何想学习(因此有问题)的人如果被要求侮辱并被告知不要问,那是不允许的.
那么yoda何时准备对他们还不知道的事情提出问题?
只是为了给您一些过去的经验,我曾经使用C C ++ flash PHP进行编程,但是自从接触编码以来已经有好几年了,几乎忘记了所有内容,因此就像我从头开始学习一样.
当我刚开始学习C ++时,我常常问一些问题以了解更多信息,因为我发现您可以从其他程序员那里学到很多东西,比从书本和通常的老师那里学到的要快得多(当时我使用这三种方法).
令我感到沮丧的是,程序员最粗鲁的尝试试图从中寻找更多信息,并且想知道为什么他们甚至不愿意回答,只是对新手施加了奇怪的侮辱,这只会使他们沮丧,并使他们在学习中更加沮丧. > 借助于庞大的程序员社区和几本书,当我确实学习了Flash和php之后,我在一年内就成为了这些书的技术审阅者,这主要是由于我的快速学习成为了一群乐于助人的好人,他们像我一样过去和现在都在Java中.
反过来,我帮助了很多其他人,只需要一个条件就可以更快地学习,这是对其他人的帮助,也不要拉扯很多人对菜鸟的态度,并记住他们也曾经是菜鸟.
因此,是的,我不再在这里问它,因为它对希望寻求帮助的菜鸟没有用.
我将以一种或另一种方式学习这种方法(如果只是从书中学习,然后从书中学习)
能够更好地从其他实际上知道自己在做什么的人那里获得更快的理解和更多的理解.
希望有一个接受菜鸟的社区,这个地方显然不是一个.
很抱歉打扰您的知识分子.
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.


这篇关于将变量传递到另一个文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆