TheSomeone
Newbie
- Joined
- Dec 24, 2004
- Messages
- 2,186
- Reaction score
- 0
What are static methods exactly? And unqualified names? And what's the default package?
AUGH! I"M DYING.
AUGH! I"M DYING.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: this_feature_currently_requires_accessing_site_using_safari
Ikerous said:Ewe.. java.. why?
public class Class1
{
public void NonStaticMethod()
{
// do stuff
}
public static void StaticMethod()
{
// do stuff
}
}
// Calling the nonstatic method requires an instantiated object:
Class1 objClass1 = new Class1();
objClass1.NonStaticMethod();
//Calling the static method does not:
Class1.StaticMethod();
DreamThrall said:no problem... from what I hear, Java and C# are very much alike, at least from an OOP perspective...
JellyWorld said:ahh java... the first language I ever learned.
A package is basically a group of classes, every class has to be in a package stated at the top of each source file, so if the package the file is in is not stated the class is said to be in the default package.
xLostx said:Circumference.java:28: operator * cannot be applied to java.lang.String,int
System.out.println("The diameter of the circle is - " + (radius * 2));
^
this makes no sense why cant i use * :\
int radius = 15;
Console.Write("The diameter of the circle is - " + (string)(radius * 2));
why doesnt this work it just returns 0.0 when its executed, im too tired to thinkimport java.io.*;
public class Circumference
{
static class Circum
{
float radius;
double diameter;
double circumference;
double area;
public Circum() throws IOException
{
BufferedReader inData =
new BufferedReader(new InputStreamReader(System.in));
float radius;
System.out.println("Enter the circles radius: ");
radius = Float.parseFloat(inData.readLine());
final double PI = 3.14159;
double diameter = (radius * 2);
double circumference = (PI *(radius * 2)) ;
double area = (PI * radius);
}
public void printCircleInfo()
{
System.out.println("The diameter of the circle is - " + diameter);
System.out.println("The circumference of the circle is - " + circumference);
System.out.println("The area of the circle is - " + area);
}
}
public static void main(String[] args) throws IOException
{
Circum text;
text = new Circum();
text.printCircleInfo();
}
}
xLostx said:why doesnt this work it just returns 0.0 when its executed, im too tired to think
ME :D said:import java.io.*;
public class Circumference
{
public static void main(String[] args) throws IOException
{
BufferedReader inData = new BufferedReader(new InputStreamReader(System.in));
float radius = Float.parseFloat(inData.readLine());
double diameter = (radius * 2);
Circum(radius);
final float PI = 3.14159;
double area = (PI * radius);
System.out.println("The diameter of the circle is - " + diameter);
System.out.println("The circumference of the circle is - " + circumference);
System.out.println("The area of the circle is - " + area);
}
public static double Circum(float x)
{
double circumference;
final double PI = 3.14159;
circumference = (PI *(x * 2));
return circumference;
}
}
import java.io.*;
public class Circumference1
{
public static void main(String[] args) throws IOException
{
BufferedReader inData = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the circles radius: ");
float radius = Float.parseFloat(inData.readLine());
double diameter = (radius * 2);
Circum(radius);
final double PI = 3.14159;
double area = Math.PI*radius*radius;
double circumference;
circumference = (PI *(radius * 2));
System.out.println("The diameter of the circle is - " + diameter);
System.out.println("The circumference of the circle is - " + circumference);
System.out.println("The area of the circle is - " + area);
}
public static double Circum(float radius)
{
double circumference;
final double PI = 3.14159;
circumference = (PI *(radius * 2));
return circumference;
}
}