Define a class called ‘twoInt’ with two public integer fields a and b
In the constructor of ‘twoInt’, initialize the a and b to be 1 and 2
Create an instance ‘mytwoInt’ in the main method
Write a method ‘swap’ (not the method of the class ‘twoInt’) and pass the above instance ‘mytwoInt’ into the method, swap two a and b in the method
Print out a and b in the main method
System.out.print(object.a + ‘ ‘ + object.b);
Swap(object);
System.out.print(object.a + ‘ ‘ + object.b);
my code
public class TwoInt
{
public static void main (String [] args)
{
int a;
int b;
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment