+ 1

Почему выдаёт ошибку я никак не могу понять

Я написал программу которя должна складывать координаты двух векторов, но почему то вылезает ошибка https://code.sololearn.com/cfMMbKyl1pH5/?ref=app

30th Nov 2020, 5:31 PM
Кирилл
1 Réponse
0
//package Programm; //packages dont work in SoloLearn public class Program{ public static void main(String[] args) { Vector v1 = new Vector(); //Vector class declared inside as inner class , so to access from static main ,make it static v1.x = 4; v1.y = 7; Vector v2 = new Vector(); v2.x = 6; v2.y = 13; vsum(v1,v2); //you need to call vsum method to work and v1,v2 needed to pass. } public static void vsum(Vector v1,Vector v2) { int sumx = v1.x + v2.x; //v1,v2 are deckared in main method so its scope is limited to main method so to access v1,v2 here you need to take those as arguments , //or in otherway , declare v1,v2 in class level, (outside main) so that you can use here, . int sumy = v1.y + v2.y; System.out.println("(" + sumx + "; " + sumy + ")"); } static class Vector { int x, y; } } //Кирилл your code has unnecessary extra space charecters,better to delete those.
30th Nov 2020, 7:50 PM
Jayakrishna 🇮🇳