system.out.println(""); syntax error

Asked

Viewed 950 times

-1

I started learning Java with the Ellipse and I’m learning more and more every day. But I came across a situation: when I use the system.out.println(""); , Eclipse "says" there is a syntax error and I have no idea what that might be. I have tried using shortcut "syso" + Ctrl+ Space but the option doesn’t even appear. I searched for answers on this and other sites but I didn’t find my problem.

The version of Eclipse I use is Eclipse IDE for Java EE Developers (Mars).

I will post an image showing the syntax error which appears together with the code.

inserir a descrição da imagem aqui

Thanks in advance! Thank you for your attention.

Code below:

package cadastro;
// 08
import java.util.ArrayList;
import java.util.HashMap;

import dados.Cliente;
import dados.Produto;
import dados.Venda;
import utilitarios.Console;

public class Cadastro {

    public static HashMap<String, Cliente> listaCliente = new HashMap<>();
    public static HashMap<Integer, Produto> listaProduto = new HashMap<>();
    public static HashMap<Integer, Venda> listaVenda = new HashMap<>();

    public static void  incluirCliente (Cliente obj ) {
        listaCliente.put(obj.getCpf(), obj);
    }

    public static void excluirCliente (Cliente obj) {
        listaCliente.remove(obj);
    }

    public static ArrayList<Cliente> pesqClienteCpf (String cpf) {
        ArrayList<Cliente> resposta = new ArrayList<>();
        for (Cliente obj : listaCliente.values()) {
            if (obj.getCpf().contains(cpf)){
                resposta.add(obj);
            }
        }
        return resposta;
    }
     // 11
    public static ArrayList<Cliente> pesqClienteNome(String nome) {
        ArrayList<Cliente> resposta = new ArrayList<>();
        for (Cliente obj : listaCliente.values()) {
            if (obj.getNome().contains(nome)) {
                resposta.add(obj);
            }
        }
        return resposta;
    }

    public static void incluirProduto (Produto obj) {
        listaProduto.put(obj.getCodigo(), obj);
    }

    public static void excluirProduto (Produto obj) {
        listaProduto.remove(obj.getCodigo());
    }

    public static ArrayList<Produto> pesqProdutoCodigo (int produto) {
        ArrayList<Produto> resposta = new ArrayList<>();
        for (Produto obj : listaProduto.values()) {
            if (obj.getCodigo() ==  produto) {
                resposta.add(obj);
            }
        }
        return resposta;
    }

    public static void incluirVenda (Venda obj) {
        listaVenda.put(obj.getNumVenda(), obj);
    }

    public static void excluirVenda (Venda obj) {
        listaVenda.remove(obj.getNumVenda());
    }
    system.out.println("asdasd");
}
  • The correct is System.out.println. The class System is with the largest S.

  • Still the same mistake. :/

  • What do you want with this command? It is useless in your code, simply remove it.

  • I know it was useless, I just didn’t understand why it was wrong. But now I understand, sorry for the question.

3 answers

3


Java is a case sensitive language. Words with uppercase and lowercase letters make a difference.

Correct: System.out.println("asdasd");

Wrong: system.out.println("asdasd");

When you can, search for Java Conventions in Google, you’ll understand how fields, classes, variables are named and learn about good practices and naming patterns...

3

You’re calling the method in the body of class, so the alert. Call System.out.println(""); within some method or constructor of its class Cadastro.

1

your problem is quite simple and it happens to most people who start in the Java world.

The System.out.println("") method starts with the larger "S" of the System Class. Try with a larger "S" and you’ll get an advance.

  • 1

    That’s just one of the problems.

  • I’ve tried with S maisculo and also put in other parts of the code, but it’s still the same thing.

  • You put it out of a method, so it won’t work either.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.