• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

type of the expression must be an array type

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]


 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
That is a really big piece of pie for such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic