Bech32 addresses start with
bc1 on the main net and
tb1 on the test net.
I want to know whether a segwit address is valid or not.
How can I check that segwit addresses are correctly inserted?
Bech32 is specified in BIP173. Native segwit outputs version 0 (P2WPKH and P2WSH) use bech32 addresses. Native segwit outputs version 1+ (P2TR) use the improved bech32m for their addresses. Bech32m is specified in BIP350.
Besides the specifications the BIPs contain test vectors which should be deployed in their entirety to verify any implementation.
A Java implementation of bech32(m) addresses can be found here in bitcoinj.
Bitcoin core command to validate an address: https://developer.bitcoin.org/reference/rpc/validateaddress.html