#Exception in thread "main" java.util.NoSuchElementException: No line found

53 messages ยท Page 1 of 1 (latest)

red kettle
#

I was JUST about to finish my code and it worked step by step but if i allow all stages to run congruently im met with this error after entering stage 2 and after it prints "enter name of the customer" Any ideas? Ive tried adding sc.nextLin(): after the string name = sc next line, ive also tried adding a system outprint with empty " "... im STUCK!

Also if i run JUST stage 2 it works, but not if i run it after stage 1

uncut auroraBOT
#

โŒ› This post has been reserved for your question.

Hey @red kettle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

red kettle
#

main method

#

Example of it breaking while all stages are active

#

oh and sorry heres the associated lines i didnt properly include in first screenshot

#

So its worked by removeing each and every sc.close(); up until the very last one? Can someone explain to me why because it showing up as warnings now that none of my stages are properly closed

calm badger
uncut auroraBOT
#

If Scanner#nextLine reads an empty line after calling a different Scanner#next method, take a look at this StackOverflow post.

radiant bloom
#

also what alex said about using a single scanner

#

why are you using a Boolean there btw

red kettle
#

oh so cool i had no idea! i thought you had to initialise scanner for each method

#

im using bool cuz im doing a do while statement that breaks if returns false @radiant bloom

radiant bloom
#

no, why Boolean

#

why not boolean

#

boolean is a boolean

#

Boolean is a wrapper for a boolean

red kettle
#

๐Ÿ˜ฎ

#

I had no idea

radiant bloom
#

it's in PascalCase, it's a class

red kettle
#

ive had 6 months of python and like 4 months of java hahaha

#

so im still very new

radiant bloom
#

like char vs Character or int vs Integer

red kettle
#

ohhhh!! no way

#

why does it still work how i want it to tho i wonder

radiant bloom
#

python's OOP is a bodge, and relative to OOP in java, c#, js, etc, it's kinda fucked tbh

red kettle
#

yeah its like going from learning your colours to learning how to paint ๐Ÿ˜„

radiant bloom
radiant bloom
#

python to java is like learning with acrylic paints then going to watercolors

#

like, same thing, same idea

#

but you have to go about them very differently

red kettle
#

thats a nicer analogy ๐Ÿ˜„

red kettle
#

so perhaps would i put the scanner sc = new scanner (system .in) under the whole booking manager class?

#

that why it wraps all the methods

radiant bloom
#

sure

#

it could also be static

red kettle
#

hmm looks like it does need to be static

#

would that be something like

#

static void scanner(){
Scanner sc = new Scanner(system,in)}

#

nah it hates that too

#

๐Ÿ˜„

radiant bloom
#

there are 8 primitives in java
integers byte, short, int, long (= int in python)
floating-points float, double (= float in python)
character char (no equivalent in python)
boolean boolean (= bool in python)

note: int and float in python are arbitrary precision, they can expand to accomodate more data, java's types aren't like this. all of these have fixed sizes

primitives, conceptually, are just the raw data, with no way to process it
that's where the wrappers come in, Byte, Short, Integer, Long, Float, Double, Character, Boolean
they have methods to process the data, and they also integrate that data into OOP structure

radiant bloom
red kettle
#

oh man

#

i think imma make a note to myself to learn this later lol its a bit too overwhelming right now ๐Ÿ˜„

#

thank you very much for you help though!!! @radiant bloom

uncut auroraBOT