Struct

Put your problem here if it does not fit any of the other categories.

Struct

Postby rex64 » Fri Feb 11, 2011 1:31 am

I am trying to find examples of all of the basic android code examples. I tried searching this site, and a number of places. Also, I am looking for someone who has Google Talk or Yahoo so I can ask code questions.

Here is what I am trying to figure out now. I want to do something like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. struct Date {
  2.     unsigned short year;
  3.     unsigned byte month;
  4.     unsigned byte day;
  5. };
  6.  
  7. union Number {
  8.     int   asInt;
  9.     float asFloat;
  10.     char  asString[12];
  11. };
  12.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I did not see anyone logged into the IRCs:
#android irc.freenode.net General discussion about Android (and Android development).
#android-dev irc.freenode.net Discussion focused on developing Android apps.
rex64
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 03, 2011 5:01 pm

Top

Re: Struct

Postby jonbonazza » Thu Mar 10, 2011 2:14 am

1) Structs do not exist in Java, and thus in the Android SDK.
Just use a class.

2) unsigned datatypes also do not exist in java/Android SDK. You can, however, use a proper signed datatype along with a bitwise &. In this case, however, your best bet is to just use the next size up.

The above would look like this in java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. class Date
  2. {
  3.      int year;
  4.      int month;
  5.      int day;
  6. }
  7.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests