Hello guys, i have been trying to play around with System.out.printf , but it says that the method is not applicable to the attributes.. i don't think i am doing anything wrong but i can't understand what's going on.. below is my code :
package com.examples; import java.util.Scanner; public class Comparison { public static void main(String[] args) { Scanner input = new Scanner( System.in ); int number1; int number2; System.out.print( "Enter first integer: " ); number1 = input.nextInt(); System.out.print( "Enter second integer: " ); number2 = input.nextInt(); if ( number1 == number2 ) System.out.printf( "%d == %d\n", number1, number2 ); if ( number1 != number2 ) System.out.printf( "%d != %d\n", number1, number2 ); if ( number1 < number2 ) System.out.printf( "%d < %d\n", number1, number2 ); if ( number1 > number2 ) System.out.printf( "%d > %d\n", number1, number2 ); if ( number1 <= number2 ) System.out.printf( "%d <= %d\n", number1, number2 ); if ( number1 >= number2 ) System.out.printf( "%d >= %d\n", number1, number2 ); } }
and this basic code :
System.out.printf( "%s\n%s\n", "Welcome to", "Java Programming!" );