public class Store { // instance fields String productType; // constructor method public Store(String product) { productType = product; } // advertise method public void advertise() { System.out.println("Selling " + productType + "!"); System.out.println("Come spend some money!"); } // main method public static void main(String[] args) { Store lemonadeStand = new Store("Lemonade"); Store Cookies = new Store("Oreos"); lemonadeStand.advertise(); Cookies.advertise(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter