Hello all, I am noob java developer and I would like to know why this is happening to my code.

Joined
Feb 14, 2025
Messages
2
Reaction score
0
So I was just making a basic program and visual studio and it is saying that I can't convert from int to short when I made the variable a short.
Here is the code part:
short years;
short anniversaries;
years = 7; // remember to make this imput based soon
anniversaries = year/4 ;
and it is saying can't convert from int to short
 
Joined
Sep 20, 2022
Messages
285
Reaction score
41
I see 3 variables.

year
years
anniversaries

Conjecture, java is treating the undeclared variable year as an integer.

I'm not a java programmer, so I could be wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,362
Messages
2,571,492
Members
48,794
Latest member
Lonell Lee

Latest Threads

Top