• Post Reply Bookmark Topic Watch Topic
  • New Topic

how do i write a struct program in java  RSS feed

 
sourav bagudai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me to write this code in java
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Can you please explain in more detail what exactly you want to do?

Does "struct" refer to "struct" as you have in C and C++? That doesn't exist in Java. In Java, you would use a class instead of a struct.
 
sourav bagudai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to write the given snapshot data in java
yeah it is the struct that we use in c/c++
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, in that case use a class instead of a struct. The usual way to do this is by creating a class with member variables and getter and setter methods. For example:

And then use the setters and getters:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!