• Post Reply Bookmark Topic Watch Topic
  • New Topic

type of the expression must be an array type  RSS feed

 
Larry Terry
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The Cobol programmer is back with a Java issue - Thanks for any help!
May be a simpler way to do this but the way I have it, seems logical to my Cobol mind..

The objective of the code is to add new records based on existing records with a partial change to the key. I'm getting "type of the expression must be an array type but it resolved to DstidArray" on dsTidRecTbl[i]


 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Larry Terry wrote:
The objective of the code is to add new records based on existing records with a partial change to the key. I'm getting "type of the expression must be an array type but it resolved to DstidArray" on dsTidRecTbl[i]


The dsTidRecTbl variable is a reference variable that points to an instance of DstidArray. It refers to an object, of class type DstidArray. And of course, it is *not* an array. You named the class type with "Array" in the name, but that doesn't make it an Array.

Which means that you can't deference it like an array.... hence, dsTidRecTbl[i], notice the square brackets, is not legal.

Henry
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Larry Terry wrote:Hello,

Hi Larry, and welcome to JavaRanch.

you should UseCodeTags (←click) whenever you post code here. I've added them for you this time - see how much better it looks? Please also also be sure to read the bit about not writing long lines, as it can make your threads hard to read - although, as an old COBOL-ite (same here) you probably won't run into those problems.

I think Henry's covered your actual problem, but your lines 4 and 5 are a bit tortuous. What about just:

  String stKey = stMajor + stMinor + stPatch;

?

Sometimes (actually quite often), simple is best.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!