That's not valid Java. You need to use assignments to assign the return values of the scanner:
MyClassBottle MilkBottle = new MyClassBottle();
System.out.println("Enter bottle material: ");
MilkBottle.material = input.next();
System.out.println("Enter bottle volume: ");
MilkBottle.volume = input.next();
That being said, the goal of this website is to make the asker a better programmer, so I'll point out other things that can be improved:
- Naming conventions: Class names are capitalized, variable names are not.
MyClassBottle MilkBottle = new MyClassBottle();
should beMyClassBottle milkBottle = new MyClassBottle();
and all accesses toMilkBottle
should get the lowercase name. - Types: As
String
, your bottle's volume could be "1.2", "100000000000000", "15L", or "green eggs and ham". You should use a more useful type for this likeint
for integers ordouble
for decimal values, and usenextInt()
ornextDouble()
on the scanner instead. - Constructors can be used to more cleanly create instances of
MyClassBottle
. Read scanner input to local variables then pass to constructor,