473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Understanding Static verses non static

I am new to Java and while I have gotten a grasp on several things, I am still uncertain about static and what it means.

I have a call I am needing to make to calculate a running total. I have this as my method:

[PHP]public double addTotal(double value)
{
total = total + value;
return total;
//method to tally value
}[/PHP]

(not sure if I am using the tags correctly, please let me know if I am not.)

and I have the call located in my main method

[PHP]CD[i].addTotal(value);//call to tally[/PHP]

While I am sure there is an easier way to do this, I am trying to get a grasp on the basics before I start using all the classes out there.

Here is my question: How can you call a method from within the main method? I have read and it seems to have something to do with my variable, value.

Thanks,

d
Jun 22 '07 #1
1 1284
r035198x
13,262 8TB
I am new to Java and while I have gotten a grasp on several things, I am still uncertain about static and what it means.

I have a call I am needing to make to calculate a running total. I have this as my method:

[PHP]public double addTotal(double value)
{
total = total + value;
return total;
//method to tally value
}[/PHP]

(not sure if I am using the tags correctly, please let me know if I am not.)

and I have the call located in my main method

[PHP]CD[i].addTotal(value);//call to tally[/PHP]

While I am sure there is an easier way to do this, I am trying to get a grasp on the basics before I start using all the classes out there.

Here is my question: How can you call a method from within the main method? I have read and it seems to have something to do with my variable, value.

Thanks,

d
Well you are using the wrong code tags. Use the # symbol and add =java in [code] so it becomes [code=java] not the < > symbol (which gives php code tags).
The static keyword is discussed here.
Jun 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: J Anderson | last post by:
Greetings, I was going through the quake2 source code (as you do) when I noticed arrays are statically allocated on the stack instead of being allocated dynamically. I’ve seen this before and...
24
by: Steven T. Hatton | last post by:
In the following code, at what point is S::c fully defined? #include <iostream> using std::cout; using std::endl; using std::ostream; class C { int _v;
13
by: Robert Lario | last post by:
C# verses VB.Net Which Way to go. I am sure this issues has come up before. Please direct me to any good articles that cover this issue. Ideally some neutral assessment. Thanks
1
by: Taylor | last post by:
"Static" is synonymous with "class" with regards to members (methods and fields) right? Sometimes I hear refrence to the "static method" and sometimes its refered to a "static method." Is there...
2
by: Tom Jones | last post by:
I have a class that contains a collection of reference types. This class needs to have a method that returns the collection to the caller. The method's signature could be either (it could also...
3
by: Tom Jones | last post by:
I do not understand what is meant when someone states that a given method is "hidden" verses overriden. Would someone please provide a short example of both cases and why you might want to...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
7
by: SpotNet | last post by:
Hello NewsGroup, Reading up on Generics in the .NET Framework 2.0 using C# 2005 (SP1), I have a question on the application of Generics. Knowingly, Generic classes are contained in the...
4
by: Andrew Taylor | last post by:
Hi, I've been using PHP for a long time, I have designed and developed a number of mid-range systems. I've always used a procedural approach. I fully understand the concept of OO, I know all the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.