java - Can't fetch result -



java - Can't fetch result -

i tried simple programme check equality of 2 numbers. defined 2 methods. first 1 numbers , sec 1 check equality. first method working fetching numbers other method yielding nothing. if come in 55 , 55, should numbers equal instead nothing. please help!

import java.util.scanner; public class check { int first; int second; string c; public void get(){ scanner s = new scanner(system.in); system.out.println("enter first number : "); first = s.nextint(); scanner p = new scanner(system.in); system.out.println("enter sec number : "); sec = p.nextint(); } public string check(){ if (first>second) { c = "first number greater"; } if (first<second) { c = "second number greater"; } if (first==second) { c = "numbers equal"; } homecoming c; } public static void main(string[] args) { check obj = new check(); obj.get(); obj.check(); } }

you returning string value,but there no statements print in main() method value gets un-utilised!

store output of obj.check() in string object , display in main method.it'll work fine!

like :-

public static void main(string[] args) { check obj = new check(); obj.get(); string s=obj.check(); system.out.println(s); }

java methods

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -