You need to sign in to do that
Don't have an account?
snowMonkey
Invalid Type Error on interface class
I am getting an invalid Type Error on the following code.
Code is from the force.com workbook example. Any suggestions as to how to resolve this error. Thanks!
public with sharing class ApexTest { public enum Season {Summer,Fall} public string modelNumber; public Integer numberInStock; public static final Integer stockThreshold = 5; public ApexTest() { modelNumber = 'XX-XX'; numberInStock = 0; system.debug('------------------------------------///////no values, but model number is : ' + modelNumber); } public ApexTest (String theModelNumber, Integer theNumberInStock) { modelNumber = theModelNumber; numberInStock = theNumberInStock; system.debug('------------------------------------///////2 values, but model number is : ' + modelNumber); } public interface KitchenUtility { String getModelNumber(); } public class Toaster implements KitchenUtility { private String modelNumber; public String getModelNumber() { return 'T' + modelNumber; } } public void setModelNumber(String theModelNumber) { modelNumber = theModelNumber; } public String getModelNumber() { return modelNumber; } } Calling code : ApexTest f = new ApexTest('MX', 200); Toaster t = New Toaster(); // This line has the error: Invalid Type Toaster KitchenUtility [] utilities = new KitchenUtility[] { f, t }; String model = utilities[0].getModelNumber(); System.debug(model);
Can you try
All Answers
Can you try
yes that was it. i got it just after i posted it.
ApexTest f = new ApexTest('MX', 200);
ApexTest.Toaster t = new ApexTest.Toaster('yy');
String model = t.getModelNumber();
System.debug('====='+model);