Home Tutorialhelp Comment Correction in the swapping programme

 
 

Comment

Dharmendra
Correction in the swapping programme,
July 27, 2009 at 11:26 PM

public class Swapping{
static void swap(int i,int j){
int temp=i;
i=j;
j=temp;
System.out.println("After swapping i = " + i + " j = " + j);
}
public static void main(String[] args){
int i=1;
int j=2;

System.out.prinln("Before swapping i="+i+" j="+j);
swap(i,j);

}
}



in this example u have mentioned the value of the two number is swap but it is to remind you that what u have done u have printed the value from the class method that is not main it is swap method and when u call the method swap in the main the value should be printed as swapped from main....


my meaning is simple that after calling the method swap in main try to print the values from the main method then u will get the answer that is not having the swap values.........



View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

swapping - Java Beginners
swapping   How to swap values of two variable without using third..., Try the following code: class Swapping { public static void main(String... = num1 - num2; num1 = num1 - num2; System.out.println("After swapping, num1 

Java Beginners

swapping - Java Beginners
new to java so plz guys if u kno the answer then plz help me!!!plzzz  Hi Friend, Try the following code: import java.util.*; class Swapping...; num2=num1-num2; num1=num1-num2; System.out.println("After swapping 

Java Interview Questions

swapping - Java Interview Questions
swapping  if input is 123456 then output should be 214365. how to do it using java code?  Hi friend, As your requirement Code to swapping : import java.io.*; public class SwapNumbers { public static void 

General

Swapping of two numbers
: C:\java>java Swapping Before swapping i = 1  j = 2 ... Swapping of two numbers       This Java programming tutorial will teach you the methods for writing 

Core Java

Swapping of two numbers in java
Swapping of two numbers in java In this example we are going to describe swapping of two numbers in java  without using the third number in java. We... values from the command prompt. The swapping of two numbers is based on simple 

General

Swapping of two numbers without using third variable
Swapping of two numbers without using third variable In this tutorial we will learn about swapping of two number in java without using third variable. This is simple program to swap two value using arithmetic operation Swapping of two 

Java Beginners

MISTAKES CORRECTION - Java Beginners
MISTAKES CORRECTION   Dear Sir, The under mentioned Java Sleep programe was received through your favor. But when I compiled, the following notes displayed in the command prompt. Note: AppletSleep.java 

Java Beginners

MISTAKES CORRECTION - Java Beginners
 

General

Dynamically Swapping Images with JavaScript
Dynamically Swapping Images with JavaScript  ... the numbers Swapping in JavaScript and create a  JavaScript program. Image Swapping in JavaScript:- In JavaScript, Numbers Swapping means interchange 

Java Beginners

programme - Java Beginners
programme  java programme to implement stack operation?use stack to check whether a given string is polidrome or not  Hi Friend, Please...://www.roseindia.net/java/example/java/util/StackImplement.shtml Use following code 

Java Beginners

Java programme - Java Beginners
Java programme  Develop a multi-threaded GUI application using java application 

Java Beginners

lucky no programme - Java Beginners
 

Java Beginners

java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method 

Java Beginners

java programme
java programme   i have to write a java programe that calculates the average of 10 students in Test 1 ,Test 2 and Test 3....Values of the marks in all the test for a student should be hardcore.Ialso have to tell the maixmum 

Java Beginners

Java programme
Java programme  Write a program to get student grade for 3 different subjects, and display the CGPA for them 

Java Beginners

menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java 

Date Calendar

Java programme - Date Calendar
Java programme  Can you provide me the coding for Date class provided by java util package 

Java Beginners

Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main 

JDBC Questions

JAVA programme - JDBC
JAVA programme  Prepare a class ?String_Example? following the basic functionality of ?String ?type of JAVA. Use of dynamic character arrays for such class is encouraged. Following is expected from the completed Program 

Java Interview Questions

JAVA programme - Java Interview Questions
JAVA programme  Perpare a class "package_example" following the basic functionality of "string" type in JAVA.Use of dynamic character arrays for such class is encouraged.Following is expected from the programme: a.Use of 3 

Java Beginners

programme
programme  Using an ATM, customer can access their bank accounts in order to credit/debit cash and check their account balances.You have to write c programme to implement a simple ATM for 15 customers. Initially you have to store 

Java Beginners

please solve the programme
please solve the programme  Develop a java program to find the roots of a quadratic equation ax2+bx+c=0, with the following specification :- Class name :- Quad Data members float a,b,c,d, with a,b,c are the co-efficient 

Java Beginners

java - Java Beginners
: class Swapping { public static void main(String[] args) { int num1 = 10... - num2; System.out.println("After swapping, num1= " + num1 + " and num2 

Applet Questions

applet images sleeping programme - Applet
-------------------------------------------------------- Read for more information. http://www.roseindia.net/java/example/java/applet/ Thanks 

Java Server Faces Questions

java programme - Java Server Faces Questions
java programme  Write a complete program, which prints all Fibonacci numbers that are less than 1600.  Hi Friend, Try the following code: public class FibonnaciSeries { public static void main(String[] args 

Java-Tutorials

Quick Sort in Java
Quick Sort in Java Quick Sort in Java is used to sort elements of an array. Quick sort works on divide and conquer strategy and comparison sort... in Java works? Quick Sort algorithm works on comparison sort that means 

Java-Tutorials

Bubble Sort in Java
Bubble Sort aka exchange sort in Java is used to sort integer values... is sorted. Swapping is followed carried out repeatedly till the list is sorted. Bubble..., it goes back to first pair. The process of comparing, swapping and returning to first 

Java Interview Questions

How to add a file in GZIP file format in Java programme.
How to add a file in GZIP file format in Java programme.  Hi please help me. How to add a file GZIP File format in Java program. If example... in Gzip file format. For details visit http://www.roseindia.net/java/examples 

Java Beginners

Core Java Doubts - Java Beginners
Core Java Doubts  1)How to swap two numbers suppose a=5 b=10; without...; Hi Friend, 1) class Swapping { public static void main(String[] args... - num2; num1 = num1 - num2; System.out.println("After swapping, num1= " + num1 

Java Beginners

java - Java Beginners
java  write a programme to count the no. of customers in bank using static variable 

Java Beginners

JAVA PROGRAMMING
JAVA PROGRAMMING  Write an OVERLOADED FUNCTION in java that swaps(interchanges) 2 user given numbers.(one integer and one float value) and displays the result after swapping. Invoke the function in a class 

IDE Questions

c programme
 

Java Beginners

Placement Programme
 

Java Beginners

java - Java Beginners
java  write a java programme to draw diagram for function f(x)=x*x 

Java Beginners

program - Java Beginners
Program and Programme Difference  What is the difference between program and programmer 

Java Beginners

programmes - Java Beginners
://www.roseindia.net/java/beginners/MatrixMultiply.shtml http://www.roseindia.net/java/beginners/MatrixSum.shtml http://www.roseindia.net/java/java-conversion/Dividing-of-two...programmes  programme to implement matrix class with addition 

Java Beginners

JAVA - Java Beginners
JAVA  WRITE A PROGRAMME FOR SIMPLE CALCULATOR  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Thanks 

Java Beginners

java - Java Beginners
java  write a programme to to implement queues using list interface  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/util/QueueImplement.shtml Thanks 

Java Beginners

Java GUI - Java Beginners
Java GUI  How to use JTray in java programme?  Hi friend, JTrayIcon jtc= new JTrayIcon(image); // jPopupMenu is a javax.swing.JPopupMenu jtc.setRightClickTarget(jPopupMenu); jtc.show(); Thanks 

Java Beginners

java - Java Beginners
java  Hii Can any ome help me to Write a programme to merge pdf iles using itext api.  Hi friend, For solving the problem visit to : http://www.roseindia.net/java/itext/ Thanks 

Java Beginners

chat - Java Beginners
chat   basic concept of chatting.. how will we connect the online users ? requirements for a chatting programme 

CVS Questions

hotel management programme in c language?
hotel management programme in c language?  hotel management programme in c language 

Java Beginners

java applets - Java Beginners
a java applet programme to implement moving a ball from top to bottom... without using swing or jframes 9.write a java programme to draw diagram for function f...java applets  1.write main method for display clock applet including 

Java Beginners

java - Java Beginners
java  1)write a java applet programme to implement moving a ball from top to bottom  Hi Friend, Please visit the following link and create applet from the code: http://www.roseindia.net/java/example/java 

Java Beginners

java - Java Beginners
java  write a programme to implement linked list using list interface  Hi Friend, Please visit the following link to learn about the implementation of LinkedList . http://www.roseindia.net/java/java-tips/data 

Java Beginners

compiling programme IJVM
compiling programme IJVM  I TRY AND COMPILE THE PROGRAMME BELOW BUT HAS ERROR APPEAR ALL THE TIME,,CAN ANYONE CORRECT THE CODE AND WRITE UP THE NEXT METHOD FOR POWER IN THE PROGRAME AS WELL...URGENT // Program to read two single 

Java Beginners

rEPLY - Java Beginners
rEPLY  hi, This is session code i am calling admin_home1.jsp then data will be not displaying its urgent requirement please send me correction Thanks   Hi friend, To display the session 

Java Beginners

Hp scanner - Java Beginners
Hp scanner  Hi guys, i would like to access hp scanner using java programme. could you refer me some useful information to proceed 

Java Interview Questions

java
pament in my account through A.T.M. tranjections or swapping machin.could u give... also...............?plz provide this process,coding(in java launguage) and your 

Java Beginners

java programming - Java Beginners
java programming  write and run a programme that accept a string from keyboard and convert it into a number.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/java-conversion 

Java Beginners

java - Java Beginners
java  write a programme for counting no. of words in a line of text using string tokeniser  Hi Friend, Use the following code: import java.util.*; public class CountWords{ public static void main(String[] args 

Java Beginners

java - Java Beginners
java  java programme to sort set of numbers in ascending order  Hi Friend, Sorting in java is very easy because of the use of Collections.sort() method. Here we are sending you the sample code to sort some numbers 

Java Beginners

developing skills in java , j2ee - Java Beginners
developing skills in java , j2ee   How to understand or to feel the flow of java or j2ee programme what is the way to become a expert programmer can you please give me tips thanking you 

Java Beginners

function arguments in java
function arguments in java  function arguments in java   Command line argument in Java import java.util.*; public class SumAndAverage... of Numbers: "+sum/10); } }   command line argument in Java - sample 

Java Beginners

Java Programming - Java Beginners
Java Programming  how to make programme to make a star with for loop in console (CUI)?  Hi friend, import java.io.*; public...(); } } } ------------------------------------------------ Read for more information. http://www.roseindia.net/java/ Thanks 

Java Beginners

java - Java Beginners
java  how to write a programme in java to copy one line file to another file.name of file are entered through a keyboard  Hi Friend, Try the following code: import java.io.*; import java.util.*; public class 

Java Beginners

java programming structure - Java Beginners
java programming structure  java programming structure  Hi Friend, The structure of Java programme is: [Package declarations] [Import statements] [Class declaration] [Method declaration] eg: package 

Java Beginners

java - Java Beginners
java  programme to sort set of strings in descending order  Hi Friend, To sort the set of String we can use overloaded method of Collections.sort(). Please try the following example code to solve your problem 

Java Tips and Examples

Beginners Java Tutorial
Beginners Java Tutorial     ... with the Java Programming language. This tutorial is for beginners, who wants to learn Java from scratch. In this beginners Java Tutorial you will learn how 

Java Beginners

java - Java Beginners
java  write a java programme to draw diagram for function f(x)=x2  Hi Friend, Here is the code which draws the diagram according to f(x) = x2 means f(1)=1*1=1 f(2)=2*2=4 .......... .......... Please try 

Java Beginners

java - Java Beginners
java  write a java programme that displays the information in the text area when store button is clicked.   Hi Friend, We are providing you a code that will display the information in text area from the database 

JSP Servlet Questions

java - JSP-Servlet
place. thanks!!  Hello Without swapping u can pay money 

Java Beginners

java - Java Beginners
java  programme to implement rational class with addition,multiplication,substraction operations  Hi Friend, Implementation of Rational Class: public class RationalClass{ private int nr; private int 

Java Beginners

java error - Java Beginners
java error  Thanks for providing me the answer for the question... be dereferenced If Programme saved in SortFileData also shows some error Please rectify the errors and provide the coding that run properly Write a Java program 

Java Interview Questions

Beginners in Java
Beginners in Java  Hi, I am beginners in Java, can someone help me... tutorials for beginners in Java with example? Thanks.   Hi, want to be command over Java, you should go on the link and follow the various beginners 

Java Beginners

java beginners - Java Beginners
the following links: http://www.roseindia.net/java/beginners/StringTokenizing.shtml http://www.roseindia.net/java/beginners/tokenizingjavasourcecode.shtml...java beginners  what is StringTokenizer? what is the funciton 

Java Beginners

HIIIIIIII - Java Beginners
used "i" instead of "p"....please make the correction thanks and reg/ prashu 

Java Beginners

Java Calculator program - Java Beginners
Java Calculator program  import java.awt.*; import javax.swing.... it to get to get 15.It 'd be helpful if u could pls suggest the possible correction...://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope 

Java Beginners

Want to Package Applocation - Java Beginners
will just click the logo of that apllication on the Deskstop and the programme 

Java Beginners

abt java project - Java Beginners
abt java project  this program compile sucessfully but data is not store in data base if any thing correction plz do it import java.awt.*; import javax.swing.*; import java.sql.*; import java.awt.event.*; public class 

Java Beginners

Java for beginners
Java for beginners  Java for beginners Which is the best resource... Java video tutorial for beginners. Thanks   Hi, Here are the best resources for Learning Java for beginners: Java Video tutorial Java tutorials 

Java Beginners

programmes - Java Beginners
programmes  programme to implement complex class with addition,multiplication,substraction operations  Hi Friend, Here is the full example code for your problem as given below. Please try the following code to solve 

Java Beginners

Java for beginners - Java Beginners
://www.roseindia.net/java/beginners/index.shtml Thanks...Java for beginners  Hi! I would like to ask you the easiest way to understand java as a beginner? Do i need to read books in advance 

Java Beginners

java beginners doubt!
java beginners doubt!  How to write clone()in java strings 

Java Beginners

programming - Java Beginners
programming for java beginners  How to start programming for java beginners 

Java Beginners

java
java  where i write java programme and how do i execute the programme 

Development process Questions

xor operator not working correctly with array
] = {2,3}; printf("before swapping: %d %d\n",a[0],a[1]); //a[0] ^= a[1]; //a[1...] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n... link http://www.roseindia.net/java/master-java/java-bitwise-xor.shtml    

Java Beginners

Good tutorials for beginners in Java
Good tutorials for beginners in Java   Hi, I am beginners in Java... in details about good tutorials for beginners in Java with example? Thanks.   ... the various beginners tutorials related to Java http://www.roseindia.net/java/beginners 

Java Beginners

making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... . But the value of check variable is not maintained in the programme . we can 

Java Beginners

Java - Java Beginners
Java  how to declare arrays   Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/array.shtml Thanks 

Java Beginners

beginners questions
beginners questions  I need all the possible Java beginners questions to prepare for an Interview 

Java Beginners

basic java - Java Beginners
basic java  oops concept in java ?  Hi Friend, Please visit the following links: http://www.roseindia.net/java/beginners/oop-in-java.shtml http://www.roseindia.net/java/learn-java-in-a-day/oops.shtml Thanks 

Java Beginners

java - Java Beginners
java  ...can you give me a sample program of insertion sorting... with a comment,,on what is algorithm..   Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/arrayexamples 

Java Beginners

java - Java Beginners
java  HOW AND WHERE SHOULD I USE A CONSTRUCTOR IN JAVA PROGRAMMING???   Hi Friend, Please visit the following links: http://www.roseindia.net/java/beginners/Construct.shtml http://www.roseindia.net/java/java 

Java Beginners

java - Java Beginners
links: http://www.roseindia.net/java/java-conversion/DecimalToBinary.shtml http://www.roseindia.net/java/beginners/DataConversion.shtml Thanks...java  write a java program that will read a positive integer 

Java Beginners

Tutorial For Java beginners
Tutorial For Java beginners  I am beginners in Java. Is there any good tutorial and example for beginners in Java? I want to learn Java before Jan... of December 2013. Check the Java Beginners Java Tutorial section for tutorials 

Java Beginners

java downloads - Java Beginners
information. http://www.roseindia.net/java/beginners/download_jdk.shtml...java downloads  hi friends, i would like to download java1.5 .so if possible please send the link for java1.5 free download  Hi friend 

Java Beginners

java beginners - Java Beginners
java beginners   pl. give few example program of signed and unsigned integer bye 

Java Beginners

java - Java Beginners
java  hi!! i want 2 download jdk latest version so can u pls send me the link..?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/download_jdk.shtml Thanks 

Java Beginners

java beginners - Java Beginners
java beginners   pl. tell me in System.out.print() what is System , what is out , print is method name . is System is a package of class name thanks   Hi Friend, System: It is a standard java class 

Java Beginners

java beginners - Java Beginners
java beginners  pl. let me know the answers of the following questions : 1) A program is unable to create objects of a class declared globally. what could be the problem wtih this construcotr 2) what is the benefit 

Java Beginners

java beginners - Java Beginners
java beginners   pl. let me know how to exterat the decimal numbers from a number i want a java program for it Example if input 12.453 OUTPUT 12 .453 if input 25.7657 OUTPUT 25 

Java Beginners

java beginners - Java Beginners
java beginners  pl. let me know the java program to get the following patteren pl. can i I get it today itself . thank you regargd a a a a a a a a a a a a a and the bewlow 

Java Beginners

java beginners - Java Beginners
java beginners   let me know the java code for the followign patteren *00 **0 *** **0 *0 0 means space whereever the stars are there that is the pattern   class user { public static void main(String 

Java Beginners

java beginners - Java Beginners
java beginners   the patteren u received is not the actual patteren which i need the program i don't know why the patteren does not reach in proper formate to you . it was in upside down triangle form . at the top 

Java Beginners

java beginners - Java Beginners
java beginners   Q. 1 How is class related to data abstraction? Q. 2 what is the relationship between a class and an object? thanks  Hi Friend, 1)Data Abstraction is used to hide certain details that we 

Java Beginners

java beginners - Java Beginners
java beginners   what are real constant? give some example of real constant. which of the following is the valid real constant. 2.0, -16.0, +15/2, 1.9E, 189.E4, 0.67E3.6  Hi Friend, A real constant is a real 

Java Beginners

java beginners - Java Beginners
java beginners  please let me know what is the difference between signed and unsigned integer thanks regards bhavna   Hi Friend, Differences: 1)Signed integer can be a negative number whereas 

Java Beginners

java beginners - Java Beginners
java beginners  the pattern was not in this format * * * * * * * * * * * * * * * * it is like this * * * * * * * * * * * * * * * * thanks   Hi Friend, If you want the following 

Java Beginners

java beginners - Java Beginners
java beginners  thanks for the suggestion so I am sending the patteren in place of dots i want blank space aaaaaaaaaaaaaaaa a............a a........a a.....a a...a a thanks 

Advertisements Advertisements
 

 

 

DMCA.com