Abhishek Kumar
Abhishek Kumar

Reputation: 17

why the complete content of this html page is not showing

I have written this code to just show the content written inside 'pre' tag and saved it as abc.html

    <pre>

        public class ReverseArr {

            public static void main(String[] args) {

                Scanner scanner = new Scanner(System.in);

                System.out.println("Enter the size of array : ");
                int n = scanner.nextInt();

                //Declaring the array
                int arr[] = new int[n];

                System.out.println("Enter the array elements : ");

                for(int i=0;i<n;i++) {
                    arr[i] = scanner.nextInt();
                }

                System.out.println("The Entered elements are : ");
                for(int i=0;i<n;i++) {
                    System.out.print(arr[i] + " ");
                }
                System.out.println();

                System.out.println("The reverse of array is : ");
                for(int i=n-1;i>=0;i--) {
                    System.out.print(arr[i] + " ");
                }
            }
        }
      </pre>

I ran it in chrome and firefox,But I am getting the output as:

    public class ReverseArr {

        public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);

            System.out.println("Enter the size of array : ");
            int n = scanner.nextInt();

            //Declaring the array
            int arr[] = new int[n];

            System.out.println("Enter the array elements : ");/*After that problem occurs*/

            for(int i=0;i=0;i--) {
                System.out.print(arr[i] + " ");
            }
        }
    }

Why the complete content is not shown in browsers (Chrome, Firefox)? What changes needs to be done to show complete content written inside 'pre' tag in browsers?

Upvotes: 1

Views: 47

Answers (1)

Anis R.
Anis R.

Reputation: 6922

As pointed out in the comments, the issue is that the angle brackets (< and >) in your code are messing up the HTML layout.

Simply replacing every < by &lt; and > by &gt; should do it.

Upvotes: 1

Related Questions