I have to write a program in java that prompts and reads the size of a table (assume the table is math square table), and plotting number and star as the following pattern in the output. For example: when reading size = 4, the table in the output should be:

***4
**34
*234
1234
so far I have this but it is not correct:

Scanner scan = new Scanner(System.in);
System.out.println("Input the size of table ");
int size = scan.nextInt();
System.out.println();

for(int row2 = 1; row2 <= size ; row2++)
{
for(int wsCount = size; wsCount < row2; wsCount--)
{
System.out.print("*");
}

for (int count2 = size-row2+1; count2 >= 1 ; count2++)
{
System.out.print(size-row2 +1);
}
}

To write a program that generates the desired pattern, you need to modify your existing code. Here's the corrected code:

```java
import java.util.Scanner;

public class SquareTablePattern {

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input the size of table: ");
int size = scan.nextInt();

System.out.println();

for (int row = 1; row <= size; row++) {

// Print whitespaces
for (int wsCount = size - row; wsCount >= 1; wsCount--) {
System.out.print(" ");
}

// Print numbers
for (int count = 1; count <= row; count++) {
System.out.print(count);
}

// Print stars
for (int starCount = 1; starCount <= size - row; starCount++) {
System.out.print("*");
}

// Print the size value
System.out.print(size);

System.out.println();
}
}
}
```

In this code, we use two nested loops to generate the pattern: one for the rows and another for the columns.

- The outer loop iterates over the rows from 1 to the given size.
- The first nested loop prints the required number of whitespaces before the numbers.
- The second nested loop prints the numbers in increasing order from 1 to the current row number.
- The third nested loop prints the stars after the numbers.
- Finally, we print the value of `size` for each row.

Compile and run the above code, and provide the desired size of the table as input to see the pattern.