How can I Read a generic value using a scanner?

Hey

I need to read from a file a certain price and company name
But because my price is a generic N type (Number), I do not know what to write instead of scanner.nextDouble();

<public class MusicalInstrument<N extends Number
{
	;private N price
	private String brand; //Company name

public MusicalInstrument(Scanner scanner)
	{
		N price;
		String brand;

		try 
		{
			price = scanner.nextDouble();
		}
		catch (InputMismatchException ex){
			throw new InputMismatchException("Price not found!");
		}
		setPrice(price);
		scanner.nextLine();
		brand = scanner.nextLine();
		setBrand(brand);
	}
 }

Author: student22
Login to Answer
Sort By:
Oldest
|
Newest
|
Vote
|
My Answer