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

Joined
Feb 15, 2025
Messages
1
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 21, 2022
Messages
227
Reaction score
36
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,249
Messages
2,571,245
Members
47,881
Latest member
eialtagu

Latest Threads

Top