Results 1 to 3 of 3
Thread: Parameters
- 12-19-2009, 05:58 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 17
- Rep Power
- 0
Parameters
Describe the differences that can occur during parameter passing in Java when the parameters are variables that store primitives vs. non-primitives.
So the parameters that store primitives basically store numbers, Double, int, etc. They pass by values. Non-primitives include objects i think, does it also include String? Objects pass by values too, but objects always object reference, so I'm bit confused. So what's the difference if I say objects pass by values and objects pass by reference? Thanks.
- 12-22-2009, 01:12 PM #2
Member
- Join Date
- Dec 2009
- Location
- Rio de Janeiro
- Posts
- 38
- Rep Power
- 0
In Java, if you change the value of a variable passed by argument inside a method , it will not change its value.
Below a list of primitive types in JavaJava Code:public class Numbers extends JFrame { public void a (int x){ x = 3; } public void a(String x){ x = "eu"; } public static void main(String[] args) { int x = 0; String xx = "vc"; System.out.println(x); System.out.println(xx); new Numbers().a(x); new Numbers().a(xx); System.out.println(x); System.out.println(xx); } }
- boolean
- char
- byte
- short
- int
- long
- float
- double
Any other value is considered non-primitive... including String.Please don't laugh at my English... I'm trying my best! :)
- 12-22-2009, 01:25 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,425
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
How to add two other parameters?
By albi_87m in forum Advanced JavaReplies: 3Last Post: 05-18-2009, 01:25 PM -
NULL Value Of parameters
By riders in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-14-2008, 02:29 PM -
Hiding parameters from URL
By Saurabh321 in forum New To JavaReplies: 0Last Post: 02-05-2008, 12:43 PM -
get parameters in jsp
By cecily in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-05-2007, 04:29 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks