Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Java, need some help please.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, Im very new to java and have some questions.
How do I display a picture for Applets.And Can I make a standalone .EXE with java?
So in java, does an "interface", only contains function prototypes and not implementation? And to write an implementation for the interface, can we only do it in the class that we implement the interface or can we do it else where too? Below is my attempt. Is this correct?
Example.
Public interface Tek-tips
{ public int doThis();
public int doThat();
}

public Forum implements Tek-tips
{
int A,B;
public Forum(int X,int Y)
{
A=X;B=Y;
}
public int doThis()
{
return A+B;
}
public int doThat()
{
return A-B;
}
}



 
Hi,

I don't know about the first two questions but you are right about interfaces. Interfaces are used to make sure a class does everything the interface specifies. They are useful because you can only extend from one superclass but you can implement as many interfaces as you like. I do not know of any other ways to use interfaces except in classes.

Your example is fine after a few cosmetic changes. Usually member variables and method variables would start with a small letter, like member methods do:

// TekTips.java
public interface TekTips
{
public int doThis();
public int doThat();
}

// Forum.java
public class Forum implements TekTips
{
int A,B;
public Forum(int X,int Y)
{
A=X;
B=Y;
}
public int doThis()
{
return A+B;
}
public int doThat()
{
return A-B;
}
}
 
Hello ,

Using java I have to find out forecast value for non-linear set of data's.
At present , I am using the below formula for forecasting the value -
a= sumofY - b* sumofX
b= n*sumof(x*y)-(sumOfX)(sumOfY)/n*sumofsquare of X-
square of sum of X

Where n is the number of records.
X - x axis values
y - y axis values.

Forecast value(y) = a+bx
for given value of x , we should get y

Same formula is used by Microsoft excel also.




There are 2 problems involved here .
1. this formula is not for non-linear data.
2. it returns negative value ( which is the rightly calculated value according to the formula).but according to my scenario, I should not this is not the right answer.

so please could u suggest a formula or any better solution.
Awaiting ur reply.Is there any java library which can give me forecast value for given set of values.



yours truly,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top