package sample; import java.io.*; public class SampleClass { public static void main(String[] args) throws IOException { Sample s = new Sample(); s.setSample("おにぎり"); System.out.println(s.buy()); } } class Sample { private String drink = "コーヒー"; private String food = "サンドイッチ"; void setSample(String eat) { food = eat; } String buy() { return drink + "と" + food + "を買いました。"; } }