🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7993

Re: How does a Java CLASS replace a C++ STRUCT?

#7993
From: John Pruitt
Date: Tue, 08 May 2001 00:26
42 lines
1675 bytes
That basically the way I've been trying to do it, but I get a NullPointerException.
It's like creating an object test does not initialize the sub class.

Here's the test program:

classTest.java
 public class classTest  {

   public static void main(String[] args) {

   test tt = new test();
  
   tt.qType=1234;
   for (int i=0;i<10;i++) {
        tt.ssList[i].sType=i;
        for (int x=0;i<17;i++)
           tt.ssList[i].sDesc[x]=(byte)(i+65);
      }
	
    }
	
 }

test.java
  public class test {
	int qType;
	int qVers;
	int qMem;
	ss[] ssList = new ss[10];
	int qFinal;
	test() {}
	}

ss.java
  public class ss {
	int sType;
	byte[] sDesc=new byte[17];
	int sValue;
	}

(Note: If I use private in ss.java like you indicated, I get compile errors)
Technical Details
Message-ID: <3af73d2d$1_2@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews
References: <3af6dd31$1_2@dnews> <3af724cb_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,f48c7921166a8f24
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-07 17:43:32 PST
From: "John Pruitt" <john@branchsoft.com>
Sender: "John Pruitt" <john@branchsoft.com>
Reply-To: "John Pruitt" <john@branchsoft.com>
Subject: Re: How does a Java CLASS replace a C++ STRUCT?
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 64.242.221.201 64.242.221.201    
References: <3af6dd31$1_2@dnews>  <3af724cb_1@dnews> 
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3af73d2d$1_2@dnews>
Date: 7 May 2001 17:26:21 -0700
X-Trace: dnews 989281581 207.105.83.65 (7 May 2001 17:26:21 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews