Below is my error which i get while i compile AppleComputer class file ( shown down below).

Any help solving this error would be appreciated .

Thanks

F:\JAVA\Java Files\Lab 5\AppleComputer.java:39: non-static method getCpuSpeed() cannot be referenced from a static context
		System.out.println("The Computer's CPU Speed Is: " + Computer.getCpuSpeed());
		                                                             ^
F:\JAVA\Java Files\Lab 5\AppleComputer.java:40: non-static method getMemorySize() cannot be referenced from a static context
		System.out.println("The Computer's Memory Size Is:" + Computer.getMemorySize());
		                                                              ^
F:\JAVA\Java Files\Lab 5\AppleComputer.java:41: non-static method getSerialNo() cannot be referenced from a static context
		System.out.println("The Computer's Serial No Is:" + Computer.getSerialNo());
		                                                            ^
3 errors

Tool completed with exit code 1
public class AppleComputer
{
	public static void main (String[] args)
	{
//		boolean succeeded;
		Computer baseModel = new Computer("IMac");
		Computer highEndModel = new Computer ("MacBook Pro", 2, 2);


//		succeeded = baseModel.overClockCpu();
//		displayOverClockInf(succeeded);


        displayOverClockInfo(baseModel.overClockedCpu());
		displayOverClockInfo(baseModel.overClockedCpu());

		displayComputerInfo(baseModel);

	}


	public static void displayOverClockInfo(boolean succeeded)
	{
		if (succeeded)
		{
			System.out.println("The CPU has been successfully overclocked" + '\n');
		}
		else
		{
			System.out.println("I am sorry that your CPU has been overcloked before " +
					           "and your request has been denied!" + '\n');
		}
	}

	public static void displayComputerInfo(Computer computer)
	{

		System.out.println("The Computer's Model NO is: " + Computer.getModel());
		System.out.println("The Computer's CPU Speed Is: " + Computer.getCpuSpeed());
		System.out.println("The Computer's Memory Size Is:" + Computer.getMemorySize());
		System.out.println("The Computer's Serial No Is:" + Computer.getSerialNo());



		//"Display information related to a computer object"
	}
}

Your displayComputerInfo() method is calling methods on Computer as if they are static, because you typed Computer instead of computer - different case. Gotta watch case-sensitivty in Java :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.