15,923,218 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13771743 (Top 4 by date)
Member 13771743
12-Apr-18 12:31pm
View
good point my bad, thank you for that even though what i really want to is how to access one class variables through another as i have shown in the above example
do i need to creat an object of that in order to use it inside another class
i found out by making it "public static" within the class (not inside a method) makes it able to use it in any class by String nm1=Class.Attribute() is it correct to make it public static just so i can use it in any class? if now how can i access a variable in one class from another tht has a value assigned to it
Member 13771743
12-Apr-18 10:14am
View
Thank you alot but i wasnt worried about finding the age i just wanted to know how to use variables from one class to another what is the correct way of doing so how bout setters and getters what role do they play
Member 13771743
10-Apr-18 12:22pm
View
@jocen i am aware of the usage of double points2=character.getHitpoints();
what i am asking is in the above one lets say i am prompting the user to enter 10 values for "10 different skills" so here i can use a for-loop or i can use 10 variables or i can store all of these inputs in an array. Lets say i did this in the character class as i have mentioned above. What if i want to use them inside another class ? is it correct for me to define those 10 variables (assuming i am using 10 variables instead of an array and what not) static so i can access them inside the other class ? Or assume i am using the array to store them is it correct for me to define the array out side an method(basically right after defining the class exactly like v done in the example) so i can use it inside another class ? if not how should i go about doing so ? is setters and gettes an option ? lets say i wanted to get this array values printed but those are inside a method in another class? is it correct for me to define them like iv done ? if not please explain how i should do so by using the example i have provided.
private static int [] arr={1,2,3}
Thnk you
Member 13771743
10-Apr-18 10:49am
View
@jocen i am aware of the usage of double points2=character.getHitpoints();
what i am asking is in the above one lets say i am prompting the user to enter 10 values for "10 different skills" so here i can use a for-loop or i can use 10 variables or i can store all of these inputs in an array. Lets say i did this in the character class as i have mentioned above. What if i want to use them inside another class ? is it correct for me to define those 10 variables (assuming i am using 10 variables instead of an array and what not) static so i can access them inside the other class ? Or assume i am using the array to store them is it correct for me to define the array out side an method(basically right after defining the class exactly like v done in the example) so i can use it inside another class ? if not how should i go about doing so ? is setters and gettes an option ? lets say i wanted to get this array values printed but those are inside a method in another class? is it correct for me to define them like iv done ? if not please explain how i should do so by using the example i have provided.
private static int [] arr={1,2,3}
Thnk you