how to achieve C# struct behavior in java -


as per msdn standard struct value type, java cannot have struct can use class instead of struct. concern use class instance value type similar c# struct. can 1 suggest me how achieve struct value type behavior in java?

class program {     static void main(string[] args)     {         demo d = new demo("value", "name");         demotes(d);         console.writeline(d.value);//prints "value" output         console.writeline(d.testvalue);//prints "namechanged" output     }     public static void demotes(demo d)     {         d.value = "valuechanged";         d.testvalue.name = "namechanged";     } } public struct demo {     public string value;     public test testvalue;     public demo(string value, string name)     {         value = value;         testvalue = new test(name);     } } public class test {     public string name;     public test(string name)     {         name = name;     } } 

in above code, need pass custom type value not reference method.

thanks in advance.

regards, sarath


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -