java - The constructor (constructor name) is undefined -



java - The constructor (constructor name) is undefined -

i'm trying create code able calculate area , perimeter of rectangles dimensions user input. of when seek phone call rectangle class create new rectangle, compiler says rectangle constructor undefined.

import java.util.scanner; public class rectangles { public class rectangle { public rectangle() {} public int length; public int width; public rectangle(int len, int wid) { length = len; width = wid; } } public void runner() { scanner scanner = new scanner(system.in); string input1 = scanner.nextline(); string input2 = scanner.nextline(); rectangle first = new rectangle(input1, input2); //error here system.out.println(first); scanner.close(); } public static void main(string[] args) {} }

the error "the constructor rectangles.rectangle(java.lang.string, java.lang.string) undefined"

the error compiler has stated - have declared constructor takes 2 int arguments, tried create rectangle using 2 strings. types incompatible. should either utilize scanner read int or utilize 1 of utility methods in integer class convert string int or integer. should aware of coding standards such capitalised class names.

java constructor

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -