• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help to solve for problem  RSS feed

 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What is wrong with this code? How to solve this?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is invalid:

'"olp"'

In Java, you write character literals between single quotes. Between the single quotes, there must be exactly one character. You have five characters between the single quotes: "olp"

I can't tell you how to solve the problem, because you gave us too little information - I can't guess what your intention was with this code.
 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to assign the value of
lblKriteriaMyocardialInfarction1 to lblKriteria[0][0],
lblKriteriaMyocardialInfarction2 to lblKriteria[1][0],
lblKriteriaMyocardialInfarction3 to lblKriteria[2][0], how to do this?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tawi Oei wrote:I want to assign the value of
lblKriteriaMyocardialInfarction1 to lblKriteria[0][0],
lblKriteriaMyocardialInfarction2 to lblKriteria[1][0],
lblKriteriaMyocardialInfarction3 to lblKriteria[2][0], how to do this?




I'm pretty sure that's not what you wanted, but it answers the question you asked, and based on the information you've provided, it's the only way to do what you say you want.

Clear, precise communication is essential in most areas of life, and programming is no exception. The person asking you to write a program has to clearly and precisely communicate his requirements to you. You have to clearly and precisely communicate to the computer what you want it to do in order to implement those requirements. And when you're having trouble, you have to clearly and precisely communicate what you're trying to do to those whose help you seek.

A few examples doesn't really tell us much. What is more helpful is 1) A clear explanation of the rules or task or pattern, along with 2) Some examples that support that.

Note, however, that when all is said and done, you cannot construct a local variable name at runtime in Java. There is no way to do "lblKriteriaMyocardialInfarction" + 1 or anything like that to refer to the variable lblKriteriaMyocardialInfarction1 if it's a local. You can do that using reflection for member variables, but that's probably not a good approach for you.

If you want to achieve an effect similar to that, then rather than naming your variables liek lblKriteriaMyocardialInfarction1, you should instead use an array or Map.
 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use arrays but I cannot do that if I want to access other class' variables, so how to do that?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tawi Oei wrote:I want to use arrays but I cannot do that if I want to access other class' variables, so how to do that?

Why can't you do that if the variables are in another class?
 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Ok, here is the code, how will you simplify the code? How to use for in this case?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt that anyone will look at 800 lines of unformatted code (or even formatted code, for that matter).
 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok look at line 603, how will you use array in this case?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean in order to pass the parameters into the method? I think I might use a HashMap instead of an array.
 
Tawi Oei
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:You mean in order to pass the parameters into the method? I think I might use a HashMap instead of an array.


Yes, but how to do that? How to implement it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!