Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

Hi

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
class Test {

public static void main(String[] args) {
m1();
}
static byte m1( ) {
final char c1 ='2';
return c1; //line 1
}
static byte m2(final char c2) {
c2='3';
return c2; //line 2
}
}

while i am compiling this code i am getting compiler error at line 2.please anybody help me
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Greetings,

The problem is that the method m2 is declared to return a byte yet it actually returns a char. A char is a 16 bit unsigned number and a byte is an 8 bit signed number so a char doesn't fit into a byte.

One solution is to declare the method m2 to return a char.

Kaydell
[ September 02, 2007: Message edited by: Kaydell Leavitt ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12202
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
as a general tip, when you post a question like "I'm getting a compiler error", it helps TREMENDOUSLY if you post the ACTUAL error you are getting.

and believe it or not, those compiler error do actually tell you what the problem is. learning to read them is a valuable skill.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12202
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
and, since this is a duplicate, i'm closing this one. Please follow up in the other thread.
 
    Bookmark Topic Watch Topic
  • New Topic