• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference betwwen private mybigdecimal and new mybigdecimal  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am an engineer who tries to understand a Java code of a program. It's my first time that I see Java language! and I'm totally confused. I hope this is the right forum to ask questions.

My question is the difference between private mybigdecimal and new mybigdecimal. For example, what does below line mean?
private MyBigDecimal UAvalue = new MyBigDecimal(0);

I mean what would be the result of such function?

Thanks a lot
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch.

Let's look at the line and pick it apart. In this line, a member variable is declared and initialized.

private MyBigDecimal UAvalue = new MyBigDecimal(0);

'private' is the access modifier of the variable. It means that the variable can only be accessed from within the class itself - code in other classes can't directly use the variable.

The first 'MyBigDecimal' is the type of the variable. 'MyBigDecimal' is a class.

'UAvalue' is the name of the variable.

The part after the = is the value that the variable is initialized with. The 'new' operator is used to create a new object. The new object that's being created is of the type MyBigDecimal. And a value 0 is passed to a constructor of class MyBigDecimal.

Have a look at Oracle's Java Tutorials or get a book - there are many books about learning Java, and Head First Java is one that many beginners like.
 
Amin Mehdipoor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Welcome to CodeRanch.

Let's look at the line and pick it apart. In this line, a member variable is declared and initialized.

private MyBigDecimal UAvalue = new MyBigDecimal(0);

'private' is the access modifier of the variable. It means that the variable can only be accessed from within the class itself - code in other classes can't directly use the variable.

The first 'MyBigDecimal' is the type of the variable. 'MyBigDecimal' is a class.

'UAvalue' is the name of the variable.

The part after the = is the value that the variable is initialized with. The 'new' operator is used to create a new object. The new object that's being created is of the type MyBigDecimal. And a value 0 is passed to a constructor of class MyBigDecimal.

Have a look at Oracle's Java Tutorials or get a book - there are many books about learning Java, and Head First Java is one that many beginners like.


Thanks a lot. what a helpful answer and explanation!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!